@@ -44,38 +44,38 @@ namespace SysML2.NET.Serializer.Xmi.Readers
4444 /// A dictionary that contains functions that return <see cref="IData"/> based a key that represents the xsi Type
4545 /// and a provided <see cref="IXmiDataCache"/>, <see cref="IExternalReferenceService" />, <see cref="ILoggerFactory"/> and <see cref="XmlReader"/>
4646 /// </summary>
47- private readonly Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, IData>> readerCache;
47+ private readonly Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, IXmiElementOriginMap, IData>> readerCache;
4848
4949 /// <summary>
5050 /// 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
5151 /// and a provided <see cref="IXmiDataCache"/>, <see cref="IExternalReferenceService" />, <see cref="ILoggerFactory"/> and <see cref="XmlReader"/>
5252 /// </summary>
53- private readonly Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, Task<IData>>> readerAsyncCache;
53+ private readonly Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, IXmiElementOriginMap, Task<IData>>> readerAsyncCache;
5454
5555 /// <summary>
5656 /// Initializes a new instance of the <see cref="XmiDataReaderFacade"/>
5757 /// </summary>
5858 public XmiDataReaderFacade()
5959 {
60- this.readerCache = new Dictionary<string, Func<IXmiDataCache, IExternalReferenceService,ILoggerFactory, XmlReader, Uri, IData>>
60+ this.readerCache = new Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, IXmiElementOriginMap , IData>>
6161 {
6262 {{ # each this as | class | }}
63- ["sysml:{{ class.Name }}"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) =>
63+ ["sysml:{{ class.Name }}"] = (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap ) =>
6464 {
6565 using var subXmlReader = xmlReader.ReadSubtree();
66- var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory);
66+ var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory, elementOriginMap );
6767 return {{ String.LowerCaseFirstLetter class.Name }}Reader.Read(subXmlReader, currentLocation);
6868 },
6969 {{/each}}
7070 };
7171
72- this.readerAsyncCache = new Dictionary<string, Func<IXmiDataCache, IExternalReferenceService,ILoggerFactory, XmlReader, Uri, Task<IData>>>
72+ this.readerAsyncCache = new Dictionary<string, Func<IXmiDataCache, IExternalReferenceService, ILoggerFactory, XmlReader, Uri, IXmiElementOriginMap , Task<IData>>>
7373 {
7474 {{ # each this as | class | }}
75- ["sysml:{{ class.Name }}"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation) =>
75+ ["sysml:{{ class.Name }}"] = async (cache, externalReferenceService, loggerFactory, xmlReader, currentLocation, elementOriginMap ) =>
7676 {
7777 using var subXmlReader = xmlReader.ReadSubtree();
78- var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory);
78+ var {{ String.LowerCaseFirstLetter class.Name }}Reader = new {{ class.Name }}Reader(cache, this, externalReferenceService, loggerFactory, elementOriginMap );
7979 return await {{ String.LowerCaseFirstLetter class.Name }}Reader.ReadAsync(subXmlReader, currentLocation);
8080 },
8181 {{/each}}
@@ -95,7 +95,7 @@ namespace SysML2.NET.Serializer.Xmi.Readers
9595 /// <param name="explicitTypeName">The explicit type name to resolve, in case of un-specified xsi:type</param>
9696 /// <returns>An instance of the read <see cref="IData"/></returns>
9797 /// <exception cref="InvalidOperationException">If the xsi:type is not supported</exception>
98- public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "")
98+ public IData QueryXmiData(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null )
9999 {
100100 AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation);
101101
@@ -107,12 +107,12 @@ namespace SysML2.NET.Serializer.Xmi.Readers
107107 }
108108
109109 xsiType ??= explicitTypeName;
110-
110+
111111 if (this.readerCache.TryGetValue(xsiType, out var readerFactory))
112112 {
113- return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation);
113+ return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap );
114114 }
115-
115+
116116 throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}");
117117 }
118118
@@ -129,24 +129,24 @@ namespace SysML2.NET.Serializer.Xmi.Readers
129129 /// <param name="explicitTypeName">The explicit type name to resolve, in case of un-specified xsi:type</param>
130130 /// <returns>An awaitable <see cref="Task" /> with the instance of the read <see cref="IData"/></returns>
131131 /// <exception cref="InvalidOperationException">If the xsi:type is not supported</exception>
132- public Task<IData> QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "")
132+ public Task<IData> QueryXmiDataAsync(XmlReader xmiReader, IXmiDataCache xmiDataCache, Uri currentLocation, IExternalReferenceService externalReferenceService, ILoggerFactory loggerFactory, string explicitTypeName = "", IXmiElementOriginMap elementOriginMap = null )
133133 {
134134 AssertValidQueryXmiDataParameters(xmiReader, xmiDataCache, currentLocation);
135-
135+
136136 var xsiType = xmiReader.GetAttribute("xsi:type");
137-
137+
138138 if (xsiType == null && string.IsNullOrEmpty(explicitTypeName))
139139 {
140140 throw new InvalidOperationException($"The xsi:type is not specified");
141141 }
142-
142+
143143 xsiType ??= explicitTypeName;
144-
144+
145145 if (this.readerAsyncCache.TryGetValue(xsiType, out var readerFactory))
146146 {
147- return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation);
147+ return readerFactory(xmiDataCache, externalReferenceService, loggerFactory, xmiReader, currentLocation, elementOriginMap );
148148 }
149-
149+
150150 throw new InvalidOperationException($"No reader found for xsi:type - {xsiType}");
151151 }
152152
0 commit comments