private string ReplaceVariables(string name) { using (new ProfileSection("Replace variables", this)) { ProfileSection.Argument("name", name); AbstractArgs abstractArgs = this.ProcessorArgs as AbstractArgs ?? this.args; var result = abstractArgs != null?Pipeline.ReplaceVariables(name, abstractArgs) : name; return(ProfileSection.Result(result)); } }
public static string ReplaceVariables([NotNull] string message, [NotNull] AbstractArgs args) { Assert.ArgumentNotNull(message, "message"); Assert.ArgumentNotNull(args, "args"); using (new ProfileSection("Replace pipeline variables in message")) { ProfileSection.Argument("message", message); ProfileSection.Argument("args", args); Type type = args.GetType(); foreach (var propertyName in message.Extract('{', '}', false)) { var propertyValue = type.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance).GetValue(args, new object[0]) as string; if (propertyValue != null) { message = message.Replace('{' + propertyName + '}', propertyValue); } } return(ProfileSection.Result(message)); } }