private void UpdateContent() { StringBuilder stringBuilder = new StringBuilder(); foreach (var key in Keys) { stringBuilder.AddKeyValue(key, this[key], this.separatorSymbol, this.pairSymbol); } Content = stringBuilder.ToString(); }
static public StringBuilder AppendObject(this StringBuilder it, object obj, bool isReturnXml) { if (obj == null) { return(it); } var type = obj.GetType(); string sb = (isReturnXml) ? "\"" : ""; foreach (var prop in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance)) { //if (!prop.CanRead) continue; var value = prop.GetValue(obj, null); it.AddKeyValue(prop.Name, sb + value + sb); } if (isReturnXml) { it.Insert(0, " ").Insert(0, type.Name).Insert(0, "<").Append("\\>"); } return(it); }
static public StringBuilder AddKeyValue(this StringBuilder it, string key, object value) { return(it.AddKeyValue(key, value, DefaultSeparatorSymbol, DefaultPairSymbol)); }