From 71453f2ce830b02cecdd0cdd419dd77125e755a4 Mon Sep 17 00:00:00 2001 From: samatstarion Date: Fri, 27 Dec 2024 13:17:13 +0100 Subject: [PATCH] [Refactor] LiteralUnlimitedNatural to be of type string instead of integer --- .../AutoGenClasses/LiteralUnlimitedNatural.cs | 4 +- .../ILiteralUnlimitedNatural.cs | 4 +- .../LiteralUnlimitedNaturalReader.cs | 192 ++++++++++++++++++ .../uml4net.CodeGenerator.Tests.csproj | 4 + uml4net.Extensions/PropertyExtensions.cs | 12 +- .../ValueSpecificationExtensions.cs | 4 +- .../LiteralUnlimitedNaturalReader.cs | 192 ++++++++++++++++++ .../Values/LiteralUnlimitedNaturalReader.cs | 133 ------------ .../AutoGenClasses/LiteralUnlimitedNatural.cs | 4 +- .../ILiteralUnlimitedNatural.cs | 4 +- .../Extend/MultiplicityElementExtensions.cs | 8 +- 11 files changed, 415 insertions(+), 146 deletions(-) create mode 100644 uml4net.CodeGenerator.Tests/Expected/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs create mode 100644 uml4net.xmi/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs delete mode 100644 uml4net.xmi/Readers/Values/LiteralUnlimitedNaturalReader.cs diff --git a/uml4net.CodeGenerator.Tests/Expected/AutoGenClasses/LiteralUnlimitedNatural.cs b/uml4net.CodeGenerator.Tests/Expected/AutoGenClasses/LiteralUnlimitedNatural.cs index 749c6d3a..a0e953d2 100644 --- a/uml4net.CodeGenerator.Tests/Expected/AutoGenClasses/LiteralUnlimitedNatural.cs +++ b/uml4net.CodeGenerator.Tests/Expected/AutoGenClasses/LiteralUnlimitedNatural.cs @@ -163,9 +163,9 @@ public IContainerList OwnedComment /// /// The specified UnlimitedNatural value. /// - [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "0")] + [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "")] [Implements(implementation: "ILiteralUnlimitedNatural.Value")] - public int Value { get; set; } + public string Value { get; set; } /// /// Determines whether and how the NamedElement is visible outside its owning Namespace. diff --git a/uml4net.CodeGenerator.Tests/Expected/AutoGenInterfaces/ILiteralUnlimitedNatural.cs b/uml4net.CodeGenerator.Tests/Expected/AutoGenInterfaces/ILiteralUnlimitedNatural.cs index e4198fec..5270bbcd 100644 --- a/uml4net.CodeGenerator.Tests/Expected/AutoGenInterfaces/ILiteralUnlimitedNatural.cs +++ b/uml4net.CodeGenerator.Tests/Expected/AutoGenInterfaces/ILiteralUnlimitedNatural.cs @@ -53,8 +53,8 @@ public partial interface ILiteralUnlimitedNatural : ILiteralSpecification /// /// The specified UnlimitedNatural value. /// - [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "0")] - public int Value { get; set; } + [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "")] + public string Value { get; set; } } } diff --git a/uml4net.CodeGenerator.Tests/Expected/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs b/uml4net.CodeGenerator.Tests/Expected/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs new file mode 100644 index 00000000..adccfe25 --- /dev/null +++ b/uml4net.CodeGenerator.Tests/Expected/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs @@ -0,0 +1,192 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 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 uml4net.xmi.Readers +{ + using System; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.InformationFlows; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class LiteralUnlimitedNaturalReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public LiteralUnlimitedNaturalReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override ILiteralUnlimitedNatural Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + var defaultLineInfo = xmlReader as IXmlLineInfo; + + ILiteralUnlimitedNatural poco = new LiteralUnlimitedNatural(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralUnlimitedNatural") + { + throw new XmlException($"The XmiType should be 'uml:LiteralUnlimitedNatural' while it is {xmiType}"); + } + else + { + xmiType = "uml:LiteralUnlimitedNatural"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + poco.Value = xmlReader.GetAttribute("value"); + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "value": + poco.Value = xmlReader.ReadElementContentAsString(); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + throw new NotSupportedException($"LiteralUnlimitedNaturalReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.CodeGenerator.Tests/uml4net.CodeGenerator.Tests.csproj b/uml4net.CodeGenerator.Tests/uml4net.CodeGenerator.Tests.csproj index 3ca36b76..c7de010a 100644 --- a/uml4net.CodeGenerator.Tests/uml4net.CodeGenerator.Tests.csproj +++ b/uml4net.CodeGenerator.Tests/uml4net.CodeGenerator.Tests.csproj @@ -58,6 +58,7 @@ + @@ -238,6 +239,9 @@ Always + + Always + Always diff --git a/uml4net.Extensions/PropertyExtensions.cs b/uml4net.Extensions/PropertyExtensions.cs index 45e108bd..40700481 100644 --- a/uml4net.Extensions/PropertyExtensions.cs +++ b/uml4net.Extensions/PropertyExtensions.cs @@ -138,7 +138,7 @@ public static bool QueryIsNumeric(this IProperty property) {"Integer", "int"}, {"Real", "double"}, {"String", "string"}, - {"UnlimitedNatural", "int"}, + {"UnlimitedNatural", "string"}, }; /// @@ -180,7 +180,15 @@ public static bool QueryIsEnumerable(this IProperty property) switch (property.UpperValue.SingleOrDefault()) { case ILiteralUnlimitedNatural literalUnlimitedNatural: - value = literalUnlimitedNatural.Value; + + if (literalUnlimitedNatural.Value == "*") + { + value = int.MaxValue; + } + else + { + value = int.Parse(literalUnlimitedNatural.Value); + } break; case ILiteralInteger literalInteger: value = literalInteger.Value; diff --git a/uml4net.Extensions/ValueSpecificationExtensions.cs b/uml4net.Extensions/ValueSpecificationExtensions.cs index dfcace78..b6911749 100644 --- a/uml4net.Extensions/ValueSpecificationExtensions.cs +++ b/uml4net.Extensions/ValueSpecificationExtensions.cs @@ -53,12 +53,12 @@ public static string QueryDefaultValueAsString(this IValueSpecification valueSpe return literalString.Value; case ILiteralUnlimitedNatural literalUnlimitedNatural: - if (literalUnlimitedNatural.Value == int.MaxValue) + if (literalUnlimitedNatural.Value == "*") { return "int.MaxValue"; } - return literalUnlimitedNatural.Value.ToString(); + return literalUnlimitedNatural.Value; case IInstanceValue instanceValue: return instanceValue.Instance.Name; default: diff --git a/uml4net.xmi/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs b/uml4net.xmi/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs new file mode 100644 index 00000000..c34d8140 --- /dev/null +++ b/uml4net.xmi/AutoGenXmiReaders/LiteralUnlimitedNaturalReader.cs @@ -0,0 +1,192 @@ +// ------------------------------------------------------------------------------------------------- +// +// +// Copyright (C) 2019-2024 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 uml4net.xmi.Readers +{ + using System; + using System.Linq; + using System.Xml; + + using Microsoft.Extensions.Logging; + + using uml4net; + using uml4net.Actions; + using uml4net.Activities; + using uml4net.Classification; + using uml4net.CommonBehavior; + using uml4net.CommonStructure; + using uml4net.Deployments; + using uml4net.InformationFlows; + using uml4net.Interactions; + using uml4net.Packages; + using uml4net.SimpleClassifiers; + using uml4net.StateMachines; + using uml4net.StructuredClassifiers; + using uml4net.UseCases; + using uml4net.Utils; + using uml4net.Values; + using uml4net.xmi.Cache; + + /// + /// The purpose of the is to read an instance of + /// from the XMI document + /// + public class LiteralUnlimitedNaturalReader : XmiElementReader, IXmiElementReader + { + private readonly IXmiElementReaderFacade xmiElementReaderFacade; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The cache in which each > is stored + /// + /// + /// The (injected) used to set up logging + /// + public LiteralUnlimitedNaturalReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) + : base(cache, loggerFactory) + { + this.xmiElementReaderFacade = new XmiElementReaderFacade(); + } + + /// + /// Reads the object from its XML representation + /// + /// + /// an instance of + /// + /// + /// an instance of + /// + public override ILiteralUnlimitedNatural Read(XmlReader xmlReader) + { + if (xmlReader == null) + { + throw new ArgumentNullException(nameof(xmlReader)); + } + + var defaultLineInfo = xmlReader as IXmlLineInfo; + + ILiteralUnlimitedNatural poco = new LiteralUnlimitedNatural(); + + if (xmlReader.MoveToContent() == XmlNodeType.Element) + { + var xmiType = xmlReader.GetAttribute("xmi:type"); + + if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralUnlimitedNatural") + { + throw new XmlException($"The XmiType should be 'uml:LiteralUnlimitedNatural' while it is {xmiType}"); + } + else + { + xmiType = "uml:LiteralUnlimitedNatural"; + } + + poco.XmiType = xmiType; + + poco.XmiId = xmlReader.GetAttribute("xmi:id"); + + this.Cache.Add(poco.XmiId, poco); + + poco.Name = xmlReader.GetAttribute("name"); + + var owningTemplateParameterXmlAttribute = xmlReader.GetAttribute("owningTemplateParameter"); + if (!string.IsNullOrEmpty(owningTemplateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("owningTemplateParameter", owningTemplateParameterXmlAttribute); + } + + var templateParameterXmlAttribute = xmlReader.GetAttribute("templateParameter"); + if (!string.IsNullOrEmpty(templateParameterXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("templateParameter", templateParameterXmlAttribute); + } + + var typeXmlAttribute = xmlReader.GetAttribute("type"); + if (!string.IsNullOrEmpty(typeXmlAttribute)) + { + poco.SingleValueReferencePropertyIdentifiers.Add("type", typeXmlAttribute); + } + + poco.Value = xmlReader.GetAttribute("value"); + + var visibilityXmlAttribute = xmlReader.GetAttribute("visibility"); + if (!string.IsNullOrEmpty(visibilityXmlAttribute)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityXmlAttribute, true); + } + + + while (xmlReader.Read()) + { + if (xmlReader.NodeType == XmlNodeType.Element) + { + switch (xmlReader.LocalName) + { + case "name": + poco.Name = xmlReader.ReadElementContentAsString(); + break; + case "nameExpression": + var nameExpressionValue = (IStringExpression)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:StringExpression"); + poco.NameExpression.Add(nameExpressionValue); + break; + case "ownedComment": + var ownedCommentValue = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); + poco.OwnedComment.Add(ownedCommentValue); + break; + case "owningTemplateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "owningTemplateParameter"); + break; + case "templateParameter": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "templateParameter"); + break; + case "type": + this.CollectSingleValueReferencePropertyIdentifier(xmlReader, poco, "type"); + break; + case "value": + poco.Value = xmlReader.ReadElementContentAsString(); + break; + case "visibility": + var visibilityValue = xmlReader.ReadElementContentAsString(); + if (!string.IsNullOrEmpty(visibilityValue)) + { + poco.Visibility = (VisibilityKind)Enum.Parse(typeof(VisibilityKind), visibilityValue, true); ; + } + break; + default: + throw new NotSupportedException($"LiteralUnlimitedNaturalReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); + } + } + } + } + + return poco; + } + } +} + +// ------------------------------------------------------------------------------------------------ +// --------THIS IS AN AUTOMATICALLY GENERATED FILE. ANY MANUAL CHANGES WILL BE OVERWRITTEN!-------- +// ------------------------------------------------------------------------------------------------ diff --git a/uml4net.xmi/Readers/Values/LiteralUnlimitedNaturalReader.cs b/uml4net.xmi/Readers/Values/LiteralUnlimitedNaturalReader.cs deleted file mode 100644 index b5205733..00000000 --- a/uml4net.xmi/Readers/Values/LiteralUnlimitedNaturalReader.cs +++ /dev/null @@ -1,133 +0,0 @@ -// ------------------------------------------------------------------------------------------------- -// -// -// Copyright 2019-2024 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, softwareUseCases -// 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 uml4net.xmi.Readers -{ - using System; - using System.Collections.Generic; - using System.Linq; - using System.Xml; - - using Microsoft.Extensions.Logging; - - using uml4net; - using uml4net.Classification; - using uml4net.CommonBehavior; - using uml4net.CommonStructure; - using uml4net.Deployments; - using uml4net.Packages; - using uml4net.SimpleClassifiers; - using uml4net.StructuredClassifiers; - using uml4net.UseCases; - using uml4net.Utils; - using uml4net.Values; - using uml4net.xmi.Cache; - using uml4net.xmi.Readers; - - /// - /// The purpose of the is to read an instance of - /// from the XMI document - /// - public class LiteralUnlimitedNaturalReader : XmiElementReader, IXmiElementReader - { - private readonly IXmiElementReaderFacade xmiElementReaderFacade; - - /// - /// Initializes a new instance of the class. - /// - /// - /// The cache in which each > is stored - /// - /// - /// The (injected) used to setup logging - /// - public LiteralUnlimitedNaturalReader(IXmiReaderCache cache, ILoggerFactory loggerFactory) - : base(cache, loggerFactory) - { - this.xmiElementReaderFacade = new XmiElementReaderFacade(); - } - - /// - /// Reads the object from its XML representation - /// - /// - /// an instance of - /// - /// - /// an instance of - /// - public override ILiteralUnlimitedNatural Read(XmlReader xmlReader) - { - Guard.ThrowIfNull(xmlReader); - - ILiteralUnlimitedNatural poco = new LiteralUnlimitedNatural(); - - if (xmlReader.MoveToContent() == XmlNodeType.Element) - { - var xmiType = xmlReader.GetAttribute("xmi:type"); - - if (!string.IsNullOrEmpty(xmiType) && xmiType != "uml:LiteralUnlimitedNatural") - { - throw new XmlException($"The XmiType should be 'uml:LiteralUnlimitedNatural' while it is {xmiType}"); - } - else - { - xmiType = "uml:LiteralUnlimitedNatural"; - } - - poco.XmiType = xmiType; - - poco.XmiId = xmlReader.GetAttribute("xmi:id"); - - this.Cache.Add(poco.XmiId, poco); - - var value = xmlReader.GetAttribute("value"); - - if (value == "*") - { - poco.Value = int.MaxValue; - } - else if (!string.IsNullOrEmpty(value)) - { - poco.Value = int.Parse(value); - } - - while (xmlReader.Read()) - { - if (xmlReader.NodeType == XmlNodeType.Element) - { - switch (xmlReader.LocalName) - { - case "ownedComment": - var ownedComment = (IComment)this.xmiElementReaderFacade.QueryXmiElement(xmlReader, this.Cache, this.LoggerFactory, "uml:Comment"); - poco.OwnedComment.Add(ownedComment); - break; - default: - var defaultLineInfo = xmlReader as IXmlLineInfo; - throw new NotSupportedException($"LiteralUnlimitedNaturalReader: {xmlReader.LocalName} at line:position {defaultLineInfo.LineNumber}:{defaultLineInfo.LinePosition}"); - } - } - } - } - - return poco; - } - } -} diff --git a/uml4net/AutoGenClasses/LiteralUnlimitedNatural.cs b/uml4net/AutoGenClasses/LiteralUnlimitedNatural.cs index 749c6d3a..a0e953d2 100644 --- a/uml4net/AutoGenClasses/LiteralUnlimitedNatural.cs +++ b/uml4net/AutoGenClasses/LiteralUnlimitedNatural.cs @@ -163,9 +163,9 @@ public IContainerList OwnedComment /// /// The specified UnlimitedNatural value. /// - [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "0")] + [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "")] [Implements(implementation: "ILiteralUnlimitedNatural.Value")] - public int Value { get; set; } + public string Value { get; set; } /// /// Determines whether and how the NamedElement is visible outside its owning Namespace. diff --git a/uml4net/AutoGenInterfaces/ILiteralUnlimitedNatural.cs b/uml4net/AutoGenInterfaces/ILiteralUnlimitedNatural.cs index e4198fec..5270bbcd 100644 --- a/uml4net/AutoGenInterfaces/ILiteralUnlimitedNatural.cs +++ b/uml4net/AutoGenInterfaces/ILiteralUnlimitedNatural.cs @@ -53,8 +53,8 @@ public partial interface ILiteralUnlimitedNatural : ILiteralSpecification /// /// The specified UnlimitedNatural value. /// - [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "0")] - public int Value { get; set; } + [Property(xmiId: "LiteralUnlimitedNatural-value", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: false, defaultValue: "")] + public string Value { get; set; } } } diff --git a/uml4net/Extend/MultiplicityElementExtensions.cs b/uml4net/Extend/MultiplicityElementExtensions.cs index 6b92dda0..23092c20 100644 --- a/uml4net/Extend/MultiplicityElementExtensions.cs +++ b/uml4net/Extend/MultiplicityElementExtensions.cs @@ -77,7 +77,13 @@ public static int QueryUpper(this IMultiplicityElement multiplicityElement) return 1; case ILiteralUnlimitedNatural literalUnlimitedNatural: - return literalUnlimitedNatural.Value; + + if (literalUnlimitedNatural.Value == "*") + { + return int.MaxValue; + } + + return int.Parse(literalUnlimitedNatural.Value); default: throw new NotSupportedException("UpperValue is not of type ILiteralUnlimitedNatural.");