public static string ReplaceDocItemTags(string html, LocalizedEntityDocumentationPage localizedDocumentationPage, ObjectConverter objectConverter) { int pos; int len; string property; var htmlBuilder = new StringBuilder(html); while ((property = FindDocItemTag(htmlBuilder.ToString(), out pos, out len)) != null) { try { var prop = localizedDocumentationPage.GetType().GetProperty(property); var propVal = prop.GetValue(localizedDocumentationPage, null); var propStr = objectConverter == null ? (propVal == null ? Resources.Null : propVal.ToString()) : objectConverter.Convert(propVal, localizedDocumentationPage.DocumentationPage); htmlBuilder.Remove(pos, len); htmlBuilder.Insert(pos, propStr); } catch (Exception ex) { throw new Exception(string.Format("Error trying to replace DocItem tag with property {0}! Message: {1}", property, ex.Message)); } } return(htmlBuilder.ToString()); }