protected string ReplacePropertyValues(Node context, string text)
{
var newText = text;
foreach (var propertyType in context.PropertyTypes)
{
newText = newText.Replace("{" + propertyType.Name + "}", context[propertyType] as string);
}
newText = newText.Replace("{Id}", context.Name).Replace("{Name}", context.Name).Replace("{Path}", context.Path).Replace("{DisplayName}", context.DisplayName);
var regex = new Regex("{.*}", RegexOptions.IgnoreCase);
var matches = regex.Match(newText);
foreach (Capture capture in matches.Captures)
{
var template = capture.Value;
var splitterPos = template.IndexOf('.');
if (splitterPos == -1)
continue;
var reference = template.Substring(1, splitterPos - 1);
var prop = template.Substring(splitterPos + 1, template.Length - splitterPos - 2);
var referenceNode = context[reference] as Node;
newText = newText.Replace(template, referenceNode[prop] as string);
}
return newText;
}