diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/CoreContractResolver.cs b/src/CSharp/EasyMicroservices.Cores.Clients/CoreContractResolver.cs new file mode 100644 index 0000000..717a874 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Clients/CoreContractResolver.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using System.Reflection; + +namespace EasyMicroservices.Cores.Clients +{ + /// + /// + /// + public class CoreContractResolver : DefaultContractResolver + { + /// + /// + /// + /// + /// + /// + protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + { + var jsonProp = base.CreateProperty(member, memberSerialization); + jsonProp.Required = Required.Default; + return jsonProp; + } + } +} \ No newline at end of file diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/CoreSerializerSettings.cs b/src/CSharp/EasyMicroservices.Cores.Clients/CoreSerializerSettings.cs new file mode 100644 index 0000000..163a91e --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Clients/CoreSerializerSettings.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace EasyMicroservices.Cores.Clients +{ + /// + /// + /// + public class CoreSerializerSettings : JsonSerializerSettings + { + /// + /// + /// + /// + public CoreSerializerSettings(JsonSerializerSettings settings) + { + this.ContractResolver = new CoreContractResolver(); + } + } +} diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/CoreSwaggerClientBase.cs b/src/CSharp/EasyMicroservices.Cores.Clients/CoreSwaggerClientBase.cs new file mode 100644 index 0000000..41a9dcc --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Clients/CoreSwaggerClientBase.cs @@ -0,0 +1,37 @@ +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; + +namespace EasyMicroservices.Cores.Clients +{ + /// + /// + /// + public abstract class CoreSwaggerClientBase + { + /// + /// + /// + public string BearerToken { get; private set; } + /// + /// + /// + /// + public void SetBearerToken(string token) + { + BearerToken = token; + } + + /// + /// + /// + /// + /// + protected Task CreateHttpRequestMessageAsync(CancellationToken cancellationToken) + { + var msg = new HttpRequestMessage(); + msg.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", BearerToken); + return Task.FromResult(msg); + } + } +} diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj new file mode 100644 index 0000000..6646008 --- /dev/null +++ b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj @@ -0,0 +1,22 @@ + + + + netstandard2.0;netstandard2.1;net6.0;net8.0 + AnyCPU;x64;x86 + EasyMicroservices + 0.0.0.51 + core of database. + EasyMicroservices@gmail.com + core,cores,base,client,clients + https://github.com/EasyMicroservices/Cores + latest + true + .\bin\$(Configuration)\$(TargetFramework)\EasyMicroservices.Cores.Clients.xml + README.md + + + + + + + diff --git a/src/CSharp/EasyMicroservices.Cores.sln b/src/CSharp/EasyMicroservices.Cores.sln index 62c8995..f4ff4f4 100644 --- a/src/CSharp/EasyMicroservices.Cores.sln +++ b/src/CSharp/EasyMicroservices.Cores.sln @@ -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 @@ -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 @@ -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}