Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Минеев Максим #233

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mineevmaxim
Copy link

Comment on lines 79 to 104
private string PrintPropertiesToString(object obj, int nestingLevel)
{
var type = obj.GetType();
var identation = new string('\t', nestingLevel + 1);
var items = (from propertyInfo in type.GetProperties()
select Serialize(propertyInfo.GetValue(obj), propertyInfo.PropertyType, propertyInfo.Name, nestingLevel + 1)
into serializedProperty
where serializedProperty != string.Empty
select identation + serializedProperty).ToList();

return string.Join(",\n", items);
}

private string PrintFieldsToString(object obj, int nestingLevel)
{
var type = obj.GetType();
var identation = new string('\t', nestingLevel + 1);
var items = (from fieldInfo in type.GetFields()
select Serialize(fieldInfo.GetValue(obj), fieldInfo.FieldType, fieldInfo.Name, nestingLevel + 1)
into serializedProperty
where serializedProperty != string.Empty
select identation + serializedProperty).ToList();

return string.Join(",\n", items);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Достаточно много дублирования

Comment on lines 122 to 126
value = PrintDictionary((IDictionary)valueToSerialize, level);
if (valueToSerialize is string stringValue && MaxLengths.TryGetValue(name, out var maxLength))
value = stringValue[..Math.Min(value.Length, maxLength)];
if (value == "") value = PrintToString(valueToSerialize, level + 1);
if (value.Length > 0) return name + " = " + value;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

давай переносы сделаем одинаковые

Comment on lines 19 to 20
private readonly HashSet<string> excludedProperties = [];
private readonly HashSet<object> visited = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Посмотри на логику visited, тоже может быть баг

Comment on lines 23 to 24
Height = 123.4,
Id = new Guid()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я бы брал не 00000000-0000-0000-0000-000000000000, а какие-то опреденные Guid

Comment on lines 10 to 11
public List<int> Weigths { get; set; }
public Dictionary<string, int> Dict { get; set; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все были связаны с человеком, а словарь просто Dict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants