Skip to content

Commit 152b3b0

Browse files
celluj34galvesribeiro
authored andcommitted
introduce specific interfaces for local and session storage (#47)
* update nuget packages * introduce interfaces for specific storage implementations * use new interfaces and make the implementations internal * register the implementation with the new interfaces * fix blazor using internal classes * update dotnet version for ci and publish
1 parent 8ef446c commit 152b3b0

File tree

10 files changed

+23
-13
lines changed

10 files changed

+23
-13
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ jobs:
1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 3.1.100-preview1-014459
18+
dotnet-version: 3.1.100-preview3-014645
1919
- name: Build
2020
run: dotnet build --configuration Release

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup .NET Core
1616
uses: actions/setup-dotnet@v1
1717
with:
18-
dotnet-version: 3.1.100-preview1-014459
18+
dotnet-version: 3.1.100-preview3-014645
1919
- name: Build
2020
run: dotnet build --configuration Release
2121
- name: Pack

src/Blazor.Extensions.Storage/Blazor.Extensions.Storage.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0-preview1.19508.20" />
20+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.0-preview3.19555.2" />
2121
</ItemGroup>
2222

2323
<ItemGroup>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Blazor.Extensions.Storage.Interfaces
2+
{
3+
public interface ILocalStorage : IStorage {}
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Blazor.Extensions.Storage.Interfaces
2+
{
3+
public interface ISessionStorage : IStorage {}
4+
}

src/Blazor.Extensions.Storage/LocalStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Blazor.Extensions.Storage
77
{
8-
public class LocalStorage : IStorage
8+
internal class LocalStorage : ILocalStorage
99
{
1010
private readonly IJSRuntime runtime;
1111

src/Blazor.Extensions.Storage/SessionStorage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Blazor.Extensions.Storage
77
{
8-
public class SessionStorage : IStorage
8+
internal class SessionStorage : ISessionStorage
99
{
1010
private readonly IJSRuntime runtime;
1111

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Blazor.Extensions.Storage.Interfaces;
12
using Microsoft.Extensions.DependencyInjection;
23

34
namespace Blazor.Extensions.Storage
@@ -6,8 +7,8 @@ public static class StorageExtensions
67
{
78
public static IServiceCollection AddStorage(this IServiceCollection services)
89
{
9-
return services.AddScoped<SessionStorage>()
10-
.AddScoped<LocalStorage>();
10+
return services.AddScoped<ISessionStorage, SessionStorage>()
11+
.AddScoped<ILocalStorage, LocalStorage>();
1112
}
1213
}
1314
}

test/Blazor.Extensions.Storage.Test/Blazor.Extensions.Storage.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview1.19508.20" />
11-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview1.19508.20" PrivateAssets="all" />
12-
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview1.19508.20" PrivateAssets="all" />
13-
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview1.19508.20" />
10+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview3.19555.2" />
11+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
13+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview3.19555.2" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

test/Blazor.Extensions.Storage.Test/Pages/Index.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
@page "/"
2-
@inject SessionStorage SessionStorage
3-
@inject LocalStorage LocalStorage
2+
@inject ISessionStorage SessionStorage
3+
@inject ILocalStorage LocalStorage
44
@inject HttpClient Http
55
@inject InteropStorage InteropStorage
66
@inject IJSRuntime JSRuntime
7+
@using Blazor.Extensions.Storage.Interfaces
78
@using Blazor.Extensions.Storage.Test.Interop
89

910
<h1>Test logging output: (See debugger log for full output)</h1>

0 commit comments

Comments
 (0)