Beispiel #1
0
        private static string GenerateInlineContent(object obj, MemberInfo[] members)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            foreach (MemberInfo Item in members)
            {
                //object fieldValue = obj.GetType().InvokeMember(Item.Name, BindingFlags.GetProperty, null, obj, null, null);
                object fieldValue       = obj.GetType().InvokeMember(Item.Name, BindingFlags.GetProperty, null, obj, null);
                string fieldValueString = ToInlineInfoString(fieldValue);

                sb.AppendPreDelimited(Item.Name + "=" + fieldValueString, ',');
            }

            return(sb.ToString());
        }
Beispiel #2
0
        private static string GenerateMultilineContent(object obj, MemberInfo[] members, int level)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            string prefix = "  ".Repeat(level) + " > ";

            foreach (MemberInfo Item in members)
            {
                // object fieldValue = obj.GetType().InvokeMember(Item.Name, BindingFlags.GetProperty, null, obj, null, null);
                object fieldValue       = obj.GetType().InvokeMember(Item.Name, BindingFlags.GetProperty, null, obj, null);
                string fieldValueString = ToMultilineInfoString(fieldValue, level + 1);

                sb.AppendPreDelimited(prefix + Item.Name + "=" + fieldValueString.TrimStart(), Environment.NewLine);
            }

            return(sb.ToString());
        }