public string Populate(params object[] contentValues) { if (contentValues == null) { throw new ArgumentNullException("contentValues"); } System.StringBuilder replacedContent = new System.StringBuilder(content); contentValues.Where(a => a.IsNotNull()).ForEachAsParallel(contentValue => { Type contentValueType = contentValue.GetType(); contentValueType.GetProperties().Where(a => a.CanRead).ForEachAsParallel(property => { string templateValue = TemplateParser.GetTemplateReplacementValue(contentValueType, property); if (replacedContent.Contains(templateValue)) { replacedContent.Replace(templateValue, property.GetValue(contentValue).ToString()); } }); }); return(replacedContent); }
public string Populate(params object[] contentValues) { if (contentValues == null) throw new ArgumentNullException("contentValues"); System.StringBuilder replacedContent = new System.StringBuilder(content); contentValues.Where(a=>a.IsNotNull()).ForEachAsParallel(contentValue => { Type contentValueType = contentValue.GetType(); contentValueType.GetProperties().Where(a => a.CanRead).ForEachAsParallel(property => { string templateValue = TemplateParser.GetTemplateReplacementValue(contentValueType, property); if (replacedContent.Contains(templateValue)) replacedContent.Replace(templateValue, property.GetValue(contentValue).ToString()); }); }); return replacedContent; }