Skip to content

Commit

Permalink
Combined cookie logic to single class with conditional logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
irwinj committed Nov 1, 2022
1 parent 42276ee commit b475b1d
Show file tree
Hide file tree
Showing 18 changed files with 266 additions and 531 deletions.
6 changes: 0 additions & 6 deletions DotNetLibrary.Client/DotNetLibrary.Client.csproj
Expand Up @@ -24,12 +24,6 @@
</PropertyGroup>

<!-- remove this and do not deploy it -->
<ItemGroup>
<Compile Remove="Microsoft\AspNetCore\Http\JSRuntimeCookieCollection.cs" />
<Compile Remove="Microsoft\AspNetCore\Http\NullHttpContext.cs" />
<Compile Remove="Microsoft\AspNetCore\Http\NullHttpRequest.cs" />
<Compile Remove="Microsoft\AspNetCore\Http\NullHttpResponse.cs" />
</ItemGroup>

<ItemGroup>
<SupportedPlatform Include="browser" />
Expand Down
114 changes: 0 additions & 114 deletions DotNetLibrary.Client/Microsoft/AspNetCore/Http/CookieManager.cs

This file was deleted.

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions DotNetLibrary.Client/Microsoft/AspNetCore/Http/NullHttpContext.cs

This file was deleted.

36 changes: 0 additions & 36 deletions DotNetLibrary.Client/Microsoft/AspNetCore/Http/NullHttpRequest.cs

This file was deleted.

28 changes: 0 additions & 28 deletions DotNetLibrary.Client/Microsoft/AspNetCore/Http/NullHttpResponse.cs

This file was deleted.

Expand Up @@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Http;

using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Serilog;
using Microsoft.JSInterop;

namespace Microsoft.Extensions.DependencyInjection;

Expand All @@ -24,8 +26,14 @@ public static class CookieExtensions
services.AddLogging();
services.AddHttpContextAccessor();

services.AddTransient<IBasicCookieManager, CookieManager>();
services.AddTransient<ICookieFactory, CookieFactory>();
services.AddTransient<IBasicCookieManager>(p =>
{
var logger = p.GetRequiredService<ILogger>();
var runtime = p.GetRequiredService<IJSRuntime>();
return new CookieManager(logger, runtime);
});

return services;
}
Expand Down
4 changes: 2 additions & 2 deletions DotNetLibrary.Core/Microsoft/AspNetCore/Http/BasicCookie.cs
Expand Up @@ -9,7 +9,7 @@ public record class BasicCookie<T>: IBasicCookie
/// <summary>
/// The underlying Cookie Manager.
/// </summary>
protected IBasicCookieManager<T> Manager { get; }
protected IBasicCookieManager Manager { get; }

/// <summary>
/// Cookie key name.
Expand All @@ -21,7 +21,7 @@ public record class BasicCookie<T>: IBasicCookie
/// </summary>
/// <param name="manager">A cookie manager for accessing the underlying cookies.</param>
/// <param name="cookieKey">The key of the cookie.</param>
public BasicCookie(IBasicCookieManager<T> manager, string cookieKey)
public BasicCookie(IBasicCookieManager manager, string cookieKey)
{
Debug.Assert(manager is not null);
Debug.Assert(cookieKey is not null);
Expand Down

0 comments on commit b475b1d

Please sign in to comment.