Skip to content

Commit

Permalink
Add support for EasyMicroservices.Cores.Clients
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Nov 25, 2023
1 parent 1956e54 commit 08941d4
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 2 deletions.
25 changes: 25 additions & 0 deletions src/CSharp/EasyMicroservices.Cores.Clients/CoreContractResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Reflection;

namespace EasyMicroservices.Cores.Clients
{
/// <summary>
///
/// </summary>
public class CoreContractResolver : DefaultContractResolver
{
/// <summary>
///
/// </summary>
/// <param name="member"></param>
/// <param name="memberSerialization"></param>
/// <returns></returns>
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
var jsonProp = base.CreateProperty(member, memberSerialization);
jsonProp.Required = Required.Default;
return jsonProp;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;

namespace EasyMicroservices.Cores.Clients
{
/// <summary>
///
/// </summary>
public class CoreSerializerSettings : JsonSerializerSettings
{
/// <summary>
///
/// </summary>
/// <param name="settings"></param>
public CoreSerializerSettings(JsonSerializerSettings settings)
{
this.ContractResolver = new CoreContractResolver();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace EasyMicroservices.Cores.Clients
{
/// <summary>
///
/// </summary>
public abstract class CoreSwaggerClientBase
{
/// <summary>
///
/// </summary>
public string BearerToken { get; private set; }
/// <summary>
///
/// </summary>
/// <param name="token"></param>
public void SetBearerToken(string token)
{
BearerToken = token;
}

/// <summary>
///
/// </summary>
/// <param name="cancellationToken"></param>
/// <returns></returns>
protected Task<HttpRequestMessage> CreateHttpRequestMessageAsync(CancellationToken cancellationToken)
{
var msg = new HttpRequestMessage();
msg.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", BearerToken);
return Task.FromResult(msg);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<Version>0.0.0.51</Version>
<Description>core of database.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>core,cores,base,client,clients</PackageTags>
<PackageProjectUrl>https://github.com/EasyMicroservices/Cores</PackageProjectUrl>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DocumentationFile>.\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.Cores.Clients.xml</DocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

</Project>
19 changes: 17 additions & 2 deletions src/CSharp/EasyMicroservices.Cores.sln
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test-Layer", "Test-Layer",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.Relational.EntityFrameworkCore", "EasyMicroservices.Cores.Relational.EntityFrameworkCore\EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj", "{2B4DE46B-911F-4C08-B506-B8D31A8B074B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyMicroservices.Cores.AspEntityFrameworkCoreApi", "EasyMicroservices.Cores.AspEntityFrameworkCoreApi\EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj", "{2A012C31-966A-427B-B685-DCB95AC299E3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.AspEntityFrameworkCoreApi", "EasyMicroservices.Cores.AspEntityFrameworkCoreApi\EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj", "{2A012C31-966A-427B-B685-DCB95AC299E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyMicroservices.Cores.AspCore.Tests", "EasyMicroservices.Cores.AspCore.Tests\EasyMicroservices.Cores.AspCore.Tests.csproj", "{243E15A6-5AD6-4304-8F91-D12666C59A0E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasyMicroservices.Cores.AspCore.Tests", "EasyMicroservices.Cores.AspCore.Tests\EasyMicroservices.Cores.AspCore.Tests.csproj", "{243E15A6-5AD6-4304-8F91-D12666C59A0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyMicroservices.Cores.Clients", "EasyMicroservices.Cores.Clients\EasyMicroservices.Cores.Clients.csproj", "{1F65B13F-F101-437C-80E7-BA4B54574D5F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -145,6 +147,18 @@ Global
{243E15A6-5AD6-4304-8F91-D12666C59A0E}.Release|x64.Build.0 = Release|Any CPU
{243E15A6-5AD6-4304-8F91-D12666C59A0E}.Release|x86.ActiveCfg = Release|Any CPU
{243E15A6-5AD6-4304-8F91-D12666C59A0E}.Release|x86.Build.0 = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|x64.ActiveCfg = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|x64.Build.0 = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|x86.ActiveCfg = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Debug|x86.Build.0 = Debug|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|Any CPU.Build.0 = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x64.ActiveCfg = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x64.Build.0 = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x86.ActiveCfg = Release|Any CPU
{1F65B13F-F101-437C-80E7-BA4B54574D5F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -159,6 +173,7 @@ Global
{2B4DE46B-911F-4C08-B506-B8D31A8B074B} = {B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B}
{2A012C31-966A-427B-B685-DCB95AC299E3} = {5F639C59-EF1C-464B-85F1-FE01E4A9F81A}
{243E15A6-5AD6-4304-8F91-D12666C59A0E} = {C2D086CC-9E2B-4152-B8F7-81E91032C17C}
{1F65B13F-F101-437C-80E7-BA4B54574D5F} = {B9CFFFCB-64BC-4E3A-982B-C50FEFE6EA9B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0E8382C1-722C-4F92-B66F-0354487C7F02}
Expand Down

0 comments on commit 08941d4

Please sign in to comment.