-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for EasyMicroservices.Cores.Clients
- Loading branch information
1 parent
1956e54
commit 08941d4
Showing
5 changed files
with
120 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/CSharp/EasyMicroservices.Cores.Clients/CoreContractResolver.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/CSharp/EasyMicroservices.Cores.Clients/CoreSerializerSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/CSharp/EasyMicroservices.Cores.Clients/CoreSwaggerClientBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters