private static string GetTsvForObject(TabularObject obj, string properties) { var props = properties.Split(','); var sb = new StringBuilder(); sb.Append(obj.GetObjectPath()); foreach (var prop in props) { sb.Append('\t'); var pInfo = obj.GetType().GetProperty(prop); if (pInfo != null) { var pValue = pInfo.GetValue(obj); if (pValue == null) { continue; } else if (pValue is TabularObject) { // Improve GetObjectPath to always provide unique path, and create corresponding method to resolve a path sb.Append((pValue as TabularObject).GetObjectPath()); } else { sb.Append(pValue.ToString().Replace("\n", "\\n").Replace("\t", "\\t")); } } } return(sb.ToString()); }
public string GetSummary() { var name = tabularObject.GetObjectPath(); if (prop == null) { return(null); } if (prop.Name == "Name") { name = name.Substring(0, name.Length - name.Length) + oldValue.ToString(); } return(string.Format("Set Property {{{0}.{1}{4}}}: \"{2}\" --> \"{3}\"", name, prop.Name, oldValue?.ToString(), newValue?.ToString(), string.IsNullOrEmpty(index) ? "" : "[" + index + "]")); }
private static string GetTsvForObject(TabularObject obj, Property[] properties) { var sb = new StringBuilder(); sb.Append(obj.GetObjectPath()); foreach (var prop in properties) { sb.Append('\t'); var pInfo = obj.GetType().GetProperty(prop.Name); if (pInfo != null) { var pValue = pInfo.GetValue(obj); if (pValue == null) { continue; } else if (pValue is TabularObject) { // Improve GetObjectPath to always provide unique path, and create corresponding method to resolve a path sb.Append((pValue as TabularObject).GetObjectPath()); } else if (prop.IsIndexer && pValue is IExpandableIndexer indexer) { sb.Append(indexer.Keys.Contains(prop.Key) ? ToString(indexer[prop.Key]) : string.Empty); } else { sb.Append(ToString(pValue)); } } } return(sb.ToString()); string ToString(object value) { return(Convert.ToString(value).Replace("\n", "\\n").Replace("\r", "\\r").Replace("\t", "\\t")); } }