Exemplo n.º 1
0
        private void AddCurrentObjectWithPropertiesToPrinting(PrintingInformation printingInformation)
        {
            var indentation  = printingInformation.CurrentIndentation;
            var nestingLevel = printingInformation.CurrentNestingLevel;
            var obj          = printingInformation.CurrentObject;
            var objFullName  = printingInformation.CurrentFullName;
            var type         = obj.GetType();

            printingInformation.AddPrintingNewLine("");

            foreach (var propertyInfo in GetNonExcludedProperties(type))
            {
                var propertyName = $"{objFullName}.{propertyInfo.Name}";
                if (IsExcludedName(propertyName))
                {
                    continue;
                }
                printingInformation.AddPrinting($"{indentation}{propertyName} = ");
                AddObjectPrinting(printingInformation, propertyInfo.GetValue(obj), nestingLevel + 1, propertyName);
            }

            foreach (var fieldInfo in GetNonExcludedFields(type))
            {
                var fieldName = $"{objFullName}.{fieldInfo.Name}";
                if (IsExcludedName(fieldName))
                {
                    continue;
                }
                printingInformation.AddPrinting($"{indentation}{fieldName} = ");
                AddObjectPrinting(printingInformation, fieldInfo.GetValue(obj), nestingLevel + 1, fieldName);
            }
        }
Exemplo n.º 2
0
        private void AddCurrentCollectionToPrinting(PrintingInformation printingInformation)
        {
            var indentation  = printingInformation.CurrentIndentation;
            var nestingLevel = printingInformation.CurrentNestingLevel;
            var collection   = printingInformation.CurrentObject as IEnumerable;
            var objFullName  = printingInformation.CurrentFullName;

            printingInformation.AddPrintingNewLine(" {");
            foreach (var obj in GetAddedObjects(collection))
            {
                printingInformation.AddPrinting(indentation);
                AddObjectPrinting(printingInformation, obj, nestingLevel + 1, $"{objFullName}.");
            }
            printingInformation.AddPrintingNewLine($"{indentation}}}");
        }
Exemplo n.º 3
0
        private void AddCurrentObjectToPrintingResult(PrintingInformation printingInformation)
        {
            var currentObject = printingInformation.CurrentObject;
            var type          = currentObject.GetType();

            printingInformation.AddPrinting(type.Name);
            if (currentObject is IEnumerable)
            {
                AddCurrentCollectionToPrinting(printingInformation);
            }
            else
            {
                AddCurrentObjectWithPropertiesToPrinting(printingInformation);
            }
        }