in src/Microsoft.Azure.NotificationHubs/BrowserTemplateRegistrationDescription.cs [108:140]
internal override void OnValidate()
{
base.OnValidate();
try
{
using (XmlReader reader = JsonReaderWriterFactory.CreateJsonReader(Encoding.UTF8.GetBytes(BodyTemplate), new XmlDictionaryReaderQuotas()))
{
XDocument payloadDocument = XDocument.Load(reader);
foreach (XElement element in payloadDocument.Root.DescendantsAndSelf())
{
foreach (XAttribute attribute in element.Attributes())
{
ExpressionEvaluator.Validate(attribute.Value);
}
if (!element.HasElements && !string.IsNullOrEmpty(element.Value))
{
ExpressionEvaluator.Validate(element.Value);
}
}
}
}
catch (InvalidOperationException)
{
// We get an ugly and misleading error message when this exception happens -> The XmlReader state should be Interactive.
// Hence we are using a more friendlier error message
throw new XmlException(SRClient.FailedToDeserializeBodyTemplate);
}
ValidateTemplateName();
}