Initial commit

This commit is contained in:
2021-06-15 10:59:47 +02:00
commit 8e156ba356
65 changed files with 1786 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Company>ITSCare GbR</Company>
<Authors>ITSCare GbR</Authors>
<Copyright>Copyright © ITSCare GbR 2021</Copyright>
<Product>ITSCare GbR Example WebApi Client</Product>
<Version>0.0.0.0</Version>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
<AssemblyInformationalVersion>0.0.0.0</AssemblyInformationalVersion>
<FileVersion>0.0.0.0</FileVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<WarningsAsErrors />
<NoWarn />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<WarningsAsErrors />
<NoWarn />
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="GerstITS.Common" Version="2021.6.17" />
<PackageReference Include="GerstITS.IoC" Version="2021.6.17" />
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2021.6.17" />
<PackageReference Include="GerstITS.System" Version="2021.6.17" />
<PackageReference Include="GerstITS.Web" Version="2021.6.17" />
<PackageReference Include="GerstITS.Web.Rest" Version="2021.6.17" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GerstITS.WebClients.Example.Api\GerstITS.Examples.WebClients.Examples.Api.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=tests_005Ccontracts/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View File

@@ -0,0 +1,25 @@
using System;
using GerstITS.Examples.WebClient.Console.Tests;
using GerstITS.IoC;
using GerstITS.IoC.DotNetCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace GerstITS.Examples.WebClient.Console
{
public class Module : IIoCModule<IServiceCollection>
{
#region IIoCModule
public void RegisterComponents(IServiceCollection container)
{
container.AddTransient<IApplicationStart, TestRunner>();
container.AddTransient<IConfiguration>(c => new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json", false, true)
.Build());
}
#endregion
}
}

View File

@@ -0,0 +1,31 @@
using GerstITS.IoC.DotNetCore;
namespace GerstITS.Examples.WebClient.Console
{
internal class Program
{
#region Fields
private static readonly DotNetCoreApplicationBootstrapper _bootstrapper;
#endregion
#region Constructors
static Program()
{
_bootstrapper = new DotNetCoreApplicationBootstrapper();
}
#endregion
#region Methods
private static void Main(string[] args)
{
_bootstrapper.Run();
}
#endregion
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Linq;
using GerstITS.Examples.WebClients.Examples.Api;
using GerstITS.IoC.DotNetCore;
using GerstITS.Web.WebClients;
namespace GerstITS.Examples.WebClient.Console.Tests
{
internal sealed class TestRunner : IApplicationStart
{
#region Fields
private readonly IWebClient _webClient;
#endregion
#region Construtors
public TestRunner(IWebClient webClient)
{
_webClient = webClient;
}
#endregion
#region ITestRunner
public void Run()
{
var result1 = _webClient.Request<ICountry>()
.Execute(c => c.Search(new SearchCriteria
{ SortBy = nameof(Country.Name), SortDirection = SortingDirections.Descending, Skip = 5, Take = 5}));
var result2 = _webClient.Request<ICountry>()
.Execute(c => c.Get(result1.Value.Result.First().Id));
var test3 = _webClient.Request<ICountry>()
.Execute(c => c.Create(new Country {Name = $"Country-{Guid.NewGuid()}"}));
test3.Value.Name += "_Renamed";
var test4 = _webClient.Request<ICountry>()
.Execute(c => c.Update(test3.Value));
var test5 = _webClient.Request<ICountry>()
.Execute(c => c.Delete(test3.Value.Id));
}
#endregion
}
}

View File

@@ -0,0 +1,13 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"ExampleApiClient": {
"BaseUrl": "https://localhost:44350/api/v1.1/"
}
}