Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 388a5f4c87 | |||
| 40f4656036 | |||
| c31dd308a4 | |||
| 11dfd18a44 | |||
| e7f02eca9b | |||
| 787507bed9 | |||
| 59af9a5406 | |||
| 5140da2c6c | |||
| 02ff14ccc8 |
@@ -11,7 +11,7 @@
|
|||||||
<!-- Quartz Scheduler-->
|
<!-- Quartz Scheduler-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bogus" Version="35.6.5" />
|
<PackageReference Include="Bogus" Version="35.6.5" />
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="3.0.101">
|
<PackageReference Include="Meziantou.Analyzer" Version="3.0.102">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -116,8 +116,8 @@
|
|||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
<!-- Amazon S3 SDK -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.4" />
|
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.5" />
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.24.1" />
|
<PackageReference Include="AWSSDK.S3" Version="4.0.24.2" />
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
||||||
|
|
||||||
<!-- global Usings -->
|
<!-- global Usings -->
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using LiteCharms.Features.Extensions;
|
using LiteCharms.Features.Extensions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Abstractions;
|
||||||
using LiteCharms.Features.MidrandBooks.Extensions;
|
using LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
|
using Microsoft.VisualStudio.TestPlatform.TestHost;
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Tests.Common;
|
namespace LiteCharms.Features.MidrandBooks.Tests.Common;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace LiteCharms.Features.MidrandBooks.Abstractions;
|
||||||
|
|
||||||
|
public interface IMidrandBooks;
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using LiteCharms.Features.Abstractions;
|
using LiteCharms.Features.Abstractions;
|
||||||
|
using LiteCharms.Features.MidrandBooks.Abstractions;
|
||||||
|
|
||||||
namespace LiteCharms.Features.MidrandBooks.Extensions;
|
namespace LiteCharms.Features.MidrandBooks.Extensions;
|
||||||
|
|
||||||
@@ -8,11 +9,15 @@ public static class Shop
|
|||||||
{
|
{
|
||||||
var serviceType = typeof(IService);
|
var serviceType = typeof(IService);
|
||||||
|
|
||||||
var implementations = Assembly.GetExecutingAssembly().GetTypes()
|
var sharedImplementations = typeof(IFeatures).Assembly.GetTypes()
|
||||||
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
|
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
|
||||||
|
|
||||||
foreach (var implementation in implementations)
|
foreach (var sharedImplementation in sharedImplementations) services.AddScoped(sharedImplementation);
|
||||||
services.AddScoped(implementation);
|
|
||||||
|
var coreImplementations = typeof(IMidrandBooks).Assembly.GetTypes()
|
||||||
|
.Where(t => serviceType.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract);
|
||||||
|
|
||||||
|
foreach (var coreImplementation in coreImplementations) services.AddScoped(coreImplementation);
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<!-- Quartz Scheduler-->
|
<!-- Quartz Scheduler-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Humanizer" Version="3.0.10" />
|
<PackageReference Include="Humanizer" Version="3.0.10" />
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="3.0.101">
|
<PackageReference Include="Meziantou.Analyzer" Version="3.0.102">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -136,8 +136,8 @@
|
|||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
<!-- Amazon S3 SDK -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.4" />
|
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.5" />
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.24.1" />
|
<PackageReference Include="AWSSDK.S3" Version="4.0.24.2" />
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
||||||
|
|
||||||
<!-- global Usings -->
|
<!-- global Usings -->
|
||||||
|
|||||||
@@ -136,8 +136,8 @@
|
|||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
<!-- Amazon S3 SDK -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.4" />
|
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.5" />
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.24.1" />
|
<PackageReference Include="AWSSDK.S3" Version="4.0.24.2" />
|
||||||
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
<ProjectReference Include="..\LiteCharms.Features\LiteCharms.Features.csproj" />
|
||||||
|
|
||||||
<!-- global Usings -->
|
<!-- global Usings -->
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace LiteCharms.Features.Abstractions;
|
||||||
|
|
||||||
|
public interface IFeatures;
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
using LiteCharms.Features.Abstractions;
|
||||||
|
|
||||||
|
namespace LiteCharms.Features.Browser;
|
||||||
|
|
||||||
|
public sealed class LocalStorageService(ProtectedLocalStorage storage) : IService
|
||||||
|
{
|
||||||
|
public async ValueTask<Result> DeleteAsync(string key)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await storage.DeleteAsync(key);
|
||||||
|
|
||||||
|
return Result.Ok();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result> SaveAsync(string key, string value)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await storage.SetAsync(key, value);
|
||||||
|
|
||||||
|
return Result.Ok();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result> SaveAsync<TValue>(string key, TValue value) where TValue : class
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await storage.SetAsync(key, value);
|
||||||
|
|
||||||
|
return Result.Ok();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<string>> GetAsync(string key)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var retrieval = await storage.GetAsync<string>(key);
|
||||||
|
|
||||||
|
return retrieval.Success && !string.IsNullOrWhiteSpace(retrieval.Value)
|
||||||
|
? Result.Ok(retrieval.Value)
|
||||||
|
: Result.Fail($"Could not find object by key {key}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<Result<TValue>> GetAsync<TValue>(string key) where TValue : class
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var retrieval = await storage.GetAsync<TValue>(key);
|
||||||
|
|
||||||
|
return retrieval.Success && retrieval.Value is not null
|
||||||
|
? Result.Ok(retrieval.Value)
|
||||||
|
: Result.Fail($"Could not find object by key {key}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result.Fail(new Error(ex.Message).CausedBy(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -104,12 +104,15 @@ public static class Api
|
|||||||
|
|
||||||
app.MapGet("/logout", async (HttpContext context) =>
|
app.MapGet("/logout", async (HttpContext context) =>
|
||||||
{
|
{
|
||||||
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
var idToken = await context.GetTokenAsync("id_token");
|
||||||
|
|
||||||
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
|
var authProperties = new AuthenticationProperties { RedirectUri = "/", };
|
||||||
{
|
|
||||||
RedirectUri = "/",
|
if (!string.IsNullOrEmpty(idToken))
|
||||||
});
|
authProperties.Parameters.Add("id_token_hint", idToken);
|
||||||
|
|
||||||
|
await context.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, authProperties);
|
||||||
|
await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
|
||||||
});
|
});
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<!-- Quartz Scheduler-->
|
<!-- Quartz Scheduler-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Hashids.net" Version="1.7.0" />
|
<PackageReference Include="Hashids.net" Version="1.7.0" />
|
||||||
<PackageReference Include="Meziantou.Analyzer" Version="3.0.101">
|
<PackageReference Include="Meziantou.Analyzer" Version="3.0.102">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@@ -171,8 +171,8 @@
|
|||||||
|
|
||||||
<!-- Amazon S3 SDK -->
|
<!-- Amazon S3 SDK -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.4" />
|
<PackageReference Include="AWSSDK.Extensions.NetCore.Setup" Version="4.0.4.5" />
|
||||||
<PackageReference Include="AWSSDK.S3" Version="4.0.24.1" />
|
<PackageReference Include="AWSSDK.S3" Version="4.0.24.2" />
|
||||||
|
|
||||||
<!-- global Usings -->
|
<!-- global Usings -->
|
||||||
<Using Include="Amazon.S3" />
|
<Using Include="Amazon.S3" />
|
||||||
@@ -182,6 +182,7 @@
|
|||||||
|
|
||||||
<!-- Shared Usings -->
|
<!-- Shared Usings -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Using Include="Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage" />
|
||||||
<Using Include="System.Reflection" />
|
<Using Include="System.Reflection" />
|
||||||
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
|
<Using Include="Microsoft.Extensions.DependencyInjection.Extensions" />
|
||||||
<Using Include="Microsoft.AspNetCore.Routing" />
|
<Using Include="Microsoft.AspNetCore.Routing" />
|
||||||
|
|||||||
Reference in New Issue
Block a user