You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// A dictionary that contains functions that return an awaitable <see cref="Task" /> with the <see cref="IData"/> based a key that represents the xsi Type
51
+
/// and a provided <see cref="IXmiDataCache"/>, <see cref="IExternalReferenceService" />, <see cref="ILoggerFactory"/> and <see cref="XmlReader"/>
/// Reads asynchronously the <see cref="I{{this.Name}}" /> object from its XML representation
151
+
/// </summary>
152
+
/// <param name="xmiReader">An instance of <see cref="XmlReader" /></param>
153
+
/// <param name="currentLocation">The <see cref="Uri" /> that keep tracks of the current location</param>
154
+
/// <returns>An awaitable <see cref="Task{TResult}"/> with the read <see cref="I{{this.Name}}" /></returns>
155
+
public override async Task<I{{this.Name}}> ReadAsync(XmlReader xmiReader, Uri currentLocation)
156
+
{
157
+
if (xmiReader == null)
158
+
{
159
+
throw new ArgumentNullException(nameof(xmiReader));
160
+
}
161
+
162
+
var xmlLineInfo = xmiReader as IXmlLineInfo;
163
+
164
+
I{{this.Name}} poco = new SysML2.NET.Core.POCO.{{ #NamedElement.WriteFullyQualifiedNameSpace this }}.{{this.Name}}();
165
+
166
+
if (await xmiReader.MoveToContentAsync() == XmlNodeType.Element)
167
+
{
168
+
this.logger.LogTrace("reading {{this.Name}} at line:position {LineNumber}:{LinePosition}", xmlLineInfo?.LineNumber, xmlLineInfo?.LinePosition);
169
+
var xsiType = xmiReader.GetAttribute("xsi:type");
170
+
171
+
if (!string.IsNullOrEmpty(xsiType) && xsiType != "sysml:{{this.Name}}")
172
+
{
173
+
throw new InvalidOperationException($"The xsi:type {xsiType} is not supported by the {{this.Name}}Reader");
174
+
}
175
+
176
+
var xmiId = xmiReader.GetAttribute("xmi:id");
177
+
178
+
if (!Guid.TryParse(xmiId, out var guid))
179
+
{
180
+
throw new InvalidOperationException($"The xmi:id {xmiId} could not be parsed");
181
+
}
182
+
183
+
poco.Id = guid;
184
+
185
+
if (!this.Cache.TryAdd(poco) && this.logger.IsEnabled(LogLevel.Critical))
186
+
{
187
+
this.logger.LogCritical("Failed to 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);
188
+
}
189
+
190
+
{{#with this as |class| }}
191
+
{{ #each (Class.QueryAllProperties this) as | property | }}
192
+
{{#unless this.IsTransient}}
193
+
{{#unless this.IsDerived}}
194
+
{{#unless (Property.IsPropertyRedefinedInClass this class)}}
0 commit comments