Skip to content

Commit

Permalink
Update formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
louisaxel-ambroise committed Apr 12, 2023
1 parent 2129380 commit 26c789e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public static XElement FormatPoll(PollResult response)
new XElement("resultsBody", new XElement(resultName, resultList))
);

if (response.EventList?.Count > 0)
{
var customNamespaces = response.EventList.SelectMany(x => x.Fields.Select(x => x.Namespace)).Where(IsCustomNamespace).Distinct().ToArray();

for (var i = 0; i < customNamespaces.Length; i++)
{
queryResults.Add(new XAttribute(XNamespace.Xmlns + $"ext{i}", customNamespaces[i]));
}
}

return queryResults;
}

Expand Down Expand Up @@ -94,4 +104,9 @@ public static XElement FormatSubscribeResponse()
{
return new(XName.Get("SubscribeResult", Namespaces.Query));
}

private static bool IsCustomNamespace(string value)
{
return !string.IsNullOrWhiteSpace(value) && XNamespace.Xmlns != value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public string FormatResult(string name, QueryResponse response)
new XElement("queryName", response.QueryName),
new XElement("subscriptionID", name),
new XElement("resultsBody", new XElement("EventList", XmlEventFormatter.FormatList(response.EventList))));
var attributes = new[] { new XAttribute("creationDate", DateTime.UtcNow), new XAttribute("schemaVersion", "1") };
var attributes = new[] { new XAttribute("creationDate", DateTime.UtcNow), new XAttribute("schemaVersion", "1.2") };

return new XElement(rootName, attributes, new XElement("EPCISBody", content)).ToString(SaveOptions.DisableFormatting);
}
Expand Down

0 comments on commit 26c789e

Please sign in to comment.