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

Савельев Григорий #192

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ObjectPrinting/Contracts/ISerializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ObjectPrinting.Contracts;

public interface ISerializer
Copy link

@elizShtol elizShtol Dec 26, 2023

Choose a reason for hiding this comment

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

Предлагаю сделать ISerializer<T>, Serialize<T>
Думаю, что так будет выглядеть логичнее

Choose a reason for hiding this comment

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

Блин, тут дженерики не отобразились в комменте сначала, сейчас поправила

{
public string Serialize(object instance, int nestingLevel);

This comment was marked as resolved.

}
17 changes: 17 additions & 0 deletions ObjectPrinting/Extensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using ObjectPrinting.Contracts;
using System;

namespace ObjectPrinting.Extensions;

public static class ObjectExtensions
{
public static string IntoString<T>(this T instance, Func<StringSerializer<T>, StringSerializer<T>> config)

This comment was marked as resolved.

Choose a reason for hiding this comment

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

Мне кажется, что такая сигнатура в целом не очень удобна

Я бы предложила такой вариант: сначала создаем сериалайзер и конфигурируем его, потом вызываем метод Serialize и передаем туда объект для сериализации.

Так будет более удобно переиспользовать сконфигурированный сериалайзер

{
return (config(new StringSerializer<T>()) as ISerializer).Serialize(instance!, 0);
}

public static string IntoString<T>(this T instance)
{
return (new StringSerializer<T>() as ISerializer).Serialize(instance!, 0);
}
}
10 changes: 0 additions & 10 deletions ObjectPrinting/ObjectPrinter.cs

This file was deleted.

17 changes: 6 additions & 11 deletions ObjectPrinting/ObjectPrinting.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

This comment was marked as resolved.


<PropertyGroup>
<LangVersion>8</LangVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="NUnit" Version="3.12.0" />
</ItemGroup>

</Project>
</Project>
41 changes: 0 additions & 41 deletions ObjectPrinting/PrintingConfig.cs

This file was deleted.

10 changes: 0 additions & 10 deletions ObjectPrinting/Solved/ObjectExtensions.cs

This file was deleted.

10 changes: 0 additions & 10 deletions ObjectPrinting/Solved/ObjectPrinter.cs

This file was deleted.

62 changes: 0 additions & 62 deletions ObjectPrinting/Solved/PrintingConfig.cs

This file was deleted.

32 changes: 0 additions & 32 deletions ObjectPrinting/Solved/PropertyPrintingConfig.cs

This file was deleted.

18 changes: 0 additions & 18 deletions ObjectPrinting/Solved/PropertyPrintingConfigExtensions.cs

This file was deleted.

40 changes: 0 additions & 40 deletions ObjectPrinting/Solved/Tests/ObjectPrinterAcceptanceTests.cs

This file was deleted.

12 changes: 0 additions & 12 deletions ObjectPrinting/Solved/Tests/Person.cs

This file was deleted.

Loading