in src/Microsoft.Azure.NotificationHubs/WindowsPhoneTemplateRegistrationDescription.cs [356:395]
void ValidateXmlPayLoad()
{
XDocument payloadDocument = XDocument.Parse(this.BodyTemplate);
this.ExpressionStartIndices = new List<int>();
this.ExpressionLengths = new List<int>();
this.Expressions = new List<string>();
IDictionary<string, int> expressionToIndexMap = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
foreach (XElement element in payloadDocument.Root.DescendantsAndSelf())
{
foreach (XAttribute attribute in element.Attributes())
{
if (ExpressionEvaluator.Validate(attribute.Value) != ExpressionEvaluator.ExpressionType.Literal)
{
// Extracts escaped expression.
// Example: id="$(id>)" --> $(id>)
string rawAttribute = attribute.ToString();
string rawAttributeValue = rawAttribute.Substring(rawAttribute.IndexOf('=') + 1);
string escapedExpression = rawAttributeValue.Substring(1, rawAttributeValue.Length - 2);
this.AddExpression(attribute.Value, escapedExpression, expressionToIndexMap);
}
}
if (!element.HasElements && !string.IsNullOrEmpty(element.Value))
{
if (ExpressionEvaluator.Validate(element.Value) != ExpressionEvaluator.ExpressionType.Literal)
{
// Extracts escaped expression.
// Example: <text id="1">$(na>me)</text> --> $(na>me)
using (XmlReader reader = element.CreateReader())
{
reader.MoveToContent();
string escapedExpression = reader.ReadInnerXml();
this.AddExpression(element.Value, escapedExpression, expressionToIndexMap);
}
}
}
}
}