Skip to content

Commit 7bb3236

Browse files
author
bird_egop
committed
Init basics
0 parents  commit 7bb3236

29 files changed

+743
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.dockerignore
2+
**/.env
3+
**/.git
4+
**/.gitignore
5+
**/.project
6+
**/.settings
7+
**/.toolstarget
8+
**/.vs
9+
**/.vscode
10+
**/.idea
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin/
2+
obj/
3+
/packages/
4+
riderModule.iml
5+
/_ReSharper.Caches/

.idea/.idea.ProjectManager/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.ProjectManager/.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.ProjectManager/.idea/indexLayout.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.ProjectManager/.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BusinessLogic/BusinessLogic.csproj

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="MediatR" Version="12.0.1" />
11+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
12+
<PackageReference Include="FluentValidation" Version="11.5.1" />
13+
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.1" />
14+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
15+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
16+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Folder Include="Mediatr" />
21+
</ItemGroup>
22+
23+
</Project>

BusinessLogic/Configs/JwtConfig.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace BusinessLogic.Configs;
2+
3+
public class JwtConfig
4+
{
5+
public string Issuer { get; set; } = null!;
6+
public string Audience { get; set; } = null!;
7+
public string Key { get; set; } = null!;
8+
9+
public int LifetimeSeconds { get; set; }
10+
public int RefreshLifetimeSeconds { get; set; }
11+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
3+
4+
namespace BusinessLogic;
5+
6+
public class DefaultValueTypeFallbackConverter : JsonConverter
7+
{
8+
public override bool CanConvert(Type objectType)
9+
{
10+
return objectType.IsValueType || Nullable.GetUnderlyingType(objectType) is not null;
11+
}
12+
13+
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
14+
{
15+
if (reader.TokenType == JsonToken.Null && Nullable.GetUnderlyingType(objectType) is not null)
16+
return null;
17+
18+
var token = JToken.Load(reader);
19+
try
20+
{
21+
return token.ToObject(objectType);
22+
}
23+
catch (Exception)
24+
{
25+
if (Nullable.GetUnderlyingType(objectType) is not null)
26+
{
27+
return null;
28+
}
29+
return GetDefaultValue(objectType);
30+
}
31+
}
32+
33+
public override bool CanWrite { get { return false; } }
34+
35+
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
36+
{
37+
throw new NotImplementedException();
38+
}
39+
40+
private static object? GetDefaultValue(Type t)
41+
{
42+
if (t.IsValueType)
43+
return Activator.CreateInstance(t);
44+
45+
return null;
46+
}
47+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Serialization;
3+
4+
namespace BusinessLogic
5+
{
6+
public static class JsonSerializerSettingsExtensions
7+
{
8+
public static JsonSerializerSettings Configure(this JsonSerializerSettings settings)
9+
{
10+
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
11+
12+
settings.DateFormatString = "yyyy-MM-ddTHH:mm:ss.fffZ";
13+
settings.Converters.Insert(0, new DefaultValueTypeFallbackConverter());
14+
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
15+
16+
17+
return settings;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)