-
Notifications
You must be signed in to change notification settings - Fork 214
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
base: master
Are you sure you want to change the base?
Савельев Григорий #192
Changes from 4 commits
06c5e77
ce88d91
9bf89b7
00aa223
827a84c
61e395e
7369414
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ObjectPrinting.Contracts; | ||
|
||
public interface ISerializer | ||
{ | ||
public string Serialize(object instance, int nestingLevel); | ||
This comment was marked as resolved.
Sorry, something went wrong. |
||
} |
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.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
} | ||
} |
This file was deleted.
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.
Sorry, something went wrong. |
||
|
||
<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> |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предлагаю сделать
ISerializer<T>, Serialize<T>
Думаю, что так будет выглядеть логичнее
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Блин, тут дженерики не отобразились в комменте сначала, сейчас поправила