in src/Microsoft.Azure.NotificationHubs/RegistrationSDKHelper.cs [148:182]
public static WindowsTemplateBodyType DetectWindowsTemplateRegistationType(string body, string errorMsg)
{
XmlDocument xmlPayload = new XmlDocument();
using (var reader = XmlTextReader.Create(new StringReader(body)))
{
try
{
xmlPayload.Load(reader);
}
catch (XmlException)
{
throw new ArgumentException(errorMsg);
}
XmlNode node = xmlPayload.FirstChild;
while (node != null && node.NodeType != XmlNodeType.Element)
{
node = node.NextSibling;
}
if (node == null)
{
throw new ArgumentException(errorMsg);
}
WindowsTemplateBodyType registrationType;
if (node == null || !Enum.TryParse(node.Name, true, out registrationType))
{
throw new ArgumentException(errorMsg);
}
return registrationType;
}
}