private static void AppendFields(object obj, Type type, OrderedHashImmutableDictionary <string, object> .OrderedHashImmutableDictionaryBuilder orderedHashImmutableDictionaryBuilder, BindingFlags options, bool includeBase) { if (type != null) { var fields = type.GetFields(options); foreach (var field in fields.Where(f => !f.Name.EndsWith("k__BackingField"))) { var value = field.GetValue(obj); orderedHashImmutableDictionaryBuilder.Put(field.Name, value); } if (includeBase) { AppendFields(obj, type.BaseType, orderedHashImmutableDictionaryBuilder, BindingFlags.NonPublic | BindingFlags.Instance, true); } } }
private static void AppendProperties(object obj, Type type, OrderedHashImmutableDictionary <string, object> .OrderedHashImmutableDictionaryBuilder orderedHashImmutableDictionaryBuilder, BindingFlags options, bool includeBase) { if (type != null) { var properties = type.GetProperties(options); foreach (var property in properties) { var value = property.GetValue(obj); orderedHashImmutableDictionaryBuilder.Put(property.Name, value); } if (includeBase) { AppendProperties(obj, type.BaseType, orderedHashImmutableDictionaryBuilder, BindingFlags.NonPublic | BindingFlags.Instance, true); } } }
private static void AppendFields(object obj, Type type, OrderedHashImmutableDictionary <string, object> .Builder builder, BindingFlags options, bool includeBase) { if (type != null) { var fields = type.GetFields(options); foreach (var field in fields) { var value = field.GetValue(obj); builder.Put(field.Name, value); } if (includeBase) { AppendFields(obj, type.BaseType, builder, BindingFlags.NonPublic | BindingFlags.Instance, true); } } }
/// <summary> /// Adds entry as 'name:value' in generated toString. /// </summary> /// <param name="name">Printed name</param> /// <param name="value">Printed value</param> /// <returns>this</returns> public ToStringHelper Add(string name, object value) { fields.Put(name, value); return(this); }