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

Add support for EasyMicroservices.Serialization.DependencyInjection #56

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.BinaryGo.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class BinaryGoExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseBinaryGo(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseBinarySerialization(() => new BinaryGoProvider());
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.1</Version>
<Version>0.0.0.2</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">

<Choose>
<When Condition="$(SolutionFileName.Contains('Net7'))">
<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;netcoreapp3.1;net6.0;net48;net7.0</TargetFrameworks>
</PropertyGroup>
</Otherwise>
</Choose>

<PropertyGroup>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.1</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
<PackageProjectUrl>https://github.com/EasyMicroservices/Serialization</PackageProjectUrl>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.Serialization.DependencyInjection.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EasyMicroservices.Serialization\EasyMicroservices.Serialization.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using EasyMicroservices.Serialization.Options;
using Microsoft.Extensions.DependencyInjection;

namespace EasyMicroservices.Serialization.AspCore
{
/// <summary>
///
/// </summary>
public static class SerializationExtensions
{
/// <summary>
///
/// </summary>
/// <param name="services"></param>
/// <param name="options"></param>
/// <returns></returns>
public static IServiceCollection AddSerialization(this IServiceCollection services, Action<SerializationOption> options)
{
options.ThrowIfNull(nameof(options));
options(new SerializationOption());
services.AddScoped(service => SerializationOptionBuilder.GetTextSerialization());
services.AddScoped(service => SerializationOptionBuilder.GetBinarySerialization());
return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.1</Version>
<Version>0.0.0.2</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
Expand All @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MemoryPack" Version="1.9.7" />
<PackageReference Include="MemoryPack" Version="1.9.16" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.MemoryPack.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class MemoryPackExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseMemoryPack(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseBinarySerialization(() => new MemoryPackProvider());
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.1</Version>
<Version>0.0.0.2</Version>
<Description>Serilize and deserilize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serilize,deserilize</PackageTags>
Expand All @@ -28,6 +28,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EasyMicroservices.Serialization\EasyMicroservices.Serialization.csproj" />
<PackageReference Include="MessagePack" Version="2.4.59" />
<PackageReference Include="MessagePack" Version="2.5.124" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.MessagePack.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class MessagePackExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseMessagePack(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseBinarySerialization(() => new MessagePackProvider());
return options;
}
}
}
18 changes: 18 additions & 0 deletions src/CSharp/EasyMicroservices.Serialization.Net7.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Implementations", "Implemen
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{976EEFD4-BC34-4649-867C-E707CD427F92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{865CD240-06DC-42CA-BAE9-D28A2EE4B10A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Serialization.DependencyInjection", "EasyMicroservices.Serialization.DependencyInjection\EasyMicroservices.Serialization.DependencyInjection.csproj", "{B6BF8207-3A9E-4366-8BA8-D30F1118392D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -147,6 +151,18 @@ Global
{579B42BC-8F4C-495C-9B53-5A5CBF86EAE3}.Release|x64.Build.0 = Release|Any CPU
{579B42BC-8F4C-495C-9B53-5A5CBF86EAE3}.Release|x86.ActiveCfg = Release|Any CPU
{579B42BC-8F4C-495C-9B53-5A5CBF86EAE3}.Release|x86.Build.0 = Release|Any CPU
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|x64.ActiveCfg = Debug|x64
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|x64.Build.0 = Debug|x64
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|x86.ActiveCfg = Debug|x86
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Debug|x86.Build.0 = Debug|x86
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|Any CPU.Build.0 = Release|Any CPU
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|x64.ActiveCfg = Release|x64
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|x64.Build.0 = Release|x64
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|x86.ActiveCfg = Release|x86
{B6BF8207-3A9E-4366-8BA8-D30F1118392D}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -164,6 +180,8 @@ Global
{98415CB1-FAFF-44FD-ABE1-F5590975ED30} = {C6B3890B-46C3-4A90-AC7C-EE4A311BA3E7}
{4C1D8DFB-8E24-48E8-BC98-84998830070B} = {C6B3890B-46C3-4A90-AC7C-EE4A311BA3E7}
{976EEFD4-BC34-4649-867C-E707CD427F92} = {C6B3890B-46C3-4A90-AC7C-EE4A311BA3E7}
{865CD240-06DC-42CA-BAE9-D28A2EE4B10A} = {C6B3890B-46C3-4A90-AC7C-EE4A311BA3E7}
{B6BF8207-3A9E-4366-8BA8-D30F1118392D} = {865CD240-06DC-42CA-BAE9-D28A2EE4B10A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7FB83286-A3A3-43D1-BCA1-593F9665E2A7}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.3</Version>
<Version>0.0.0.4</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
Expand All @@ -28,6 +28,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EasyMicroservices.Serialization\EasyMicroservices.Serialization.csproj" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.Newtonsoft.Json.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class NewtonsoftJsonExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseNewtonsoftJson(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseTextSerialization(() => new NewtonsoftJsonProvider());
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.4</Version>
<Version>0.0.0.5</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
Expand All @@ -28,7 +28,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="7.0.1" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EasyMicroservices.Serialization\EasyMicroservices.Serialization.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.System.Text.Json.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class SystemTextJsonExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseSystemTextJson(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseTextSerialization(() => new SystemTextJsonProvider());
return options;
}

/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseSystemTextJsonBinary(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseBinarySerialization(() => new SystemTextJsonBinaryProvider());
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.1</Version>
<Version>0.0.0.2</Version>
<Description>Serialize and deserialize wrapper</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>Serialize,deserialize</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using EasyMicroservices.Serialization.Options;
using EasyMicroservices.Serialization.System.Text.Xml.Providers;

namespace EasyMicroservices.Serialization
{
/// <summary>
///
/// </summary>
public static class SystemTextXmlExtensions
{
/// <summary>
///
/// </summary>
/// <param name="options"></param>
/// <returns></returns>
public static SerializationOption UseSystemTextXml(this SerializationOption options)
{
options.ThrowIfNull(nameof(options));
SerializationOptionBuilder.UseTextSerialization(() => new SystemTextXmlProvider());
return options;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,29 @@
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'net452' or '$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Otherwise>
</Choose>

<ItemGroup>
<PackageReference Include="EasyMicroservices.Tests" Version="0.0.0.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="EasyMicroservices.Tests" Version="0.0.0.7" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit.assert" Version="2.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading