Skip to content

Commit e07ce27

Browse files
DanielCarminghamgalvesribeiro
authored andcommitted
Updated for Blazor 3.0.0-preview4. (#22)
* Updates for 3.0.0-preview for compatibility. Also removed BlazorExtensions.Logging dependency from Test project. * Added dotnet core installer for 3.0.100-preview4 to CI * Removed myget.org package sources
1 parent bb19be4 commit e07ce27

File tree

17 files changed

+160
-113
lines changed

17 files changed

+160
-113
lines changed

.vsts-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ variables:
44
buildConfiguration: 'Release'
55

66
steps:
7+
- task: DotNetCoreInstaller@0
8+
inputs:
9+
packageType: 'sdk'
10+
version: '3.0.100-preview4-011223'
11+
712
- task: Npm@1
813
inputs:
914
command: 'install'

.vsts-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ variables:
44
buildConfiguration: 'Release'
55

66
steps:
7+
- task: DotNetCoreInstaller@0
8+
inputs:
9+
packageType: 'sdk'
10+
version: '3.0.100-preview4-011223'
11+
712
- task: Npm@1
813
inputs:
914
command: 'install'

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
19+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
2020
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
2121
</ItemGroup>
2222

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<Title>Blazor Extensions Storage</Title>
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Blazor.Extensions.Storage/LocalStorage.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,38 @@ namespace Blazor.Extensions.Storage
77
{
88
public class LocalStorage : IStorage
99
{
10-
public Task<int> Length() => JSRuntime.Current.InvokeAsync<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.LOCAL_STORAGE);
11-
public Task Clear() => JSRuntime.Current.InvokeAsync<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.LOCAL_STORAGE);
10+
private readonly IJSRuntime runtime;
11+
12+
public Task<int> Length() => this.runtime.InvokeAsync<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.LOCAL_STORAGE);
13+
14+
public Task Clear() => this.runtime.InvokeAsync<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.LOCAL_STORAGE);
15+
16+
public LocalStorage(IJSRuntime runtime)
17+
{
18+
this.runtime = runtime;
19+
}
1220

1321
public Task<TItem> GetItem<TItem>(string key)
1422
{
1523
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
1624

17-
return JSRuntime.Current.InvokeAsync<TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key);
25+
return this.runtime.InvokeAsync<TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key);
1826
}
1927

20-
public Task<string> Key(int index) => JSRuntime.Current.InvokeAsync<string>(MethodNames.KEY_METHOD, StorageTypeNames.LOCAL_STORAGE, index);
28+
public Task<string> Key(int index) => this.runtime.InvokeAsync<string>(MethodNames.KEY_METHOD, StorageTypeNames.LOCAL_STORAGE, index);
2129

2230
public Task RemoveItem(string key)
2331
{
2432
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
2533

26-
return JSRuntime.Current.InvokeAsync<object>(MethodNames.REMOVE_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key);
34+
return this.runtime.InvokeAsync<object>(MethodNames.REMOVE_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key);
2735
}
2836

2937
public Task SetItem<TItem>(string key, TItem item)
3038
{
3139
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
3240

33-
return JSRuntime.Current.InvokeAsync<object>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key, item);
41+
return this.runtime.InvokeAsync<object>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.LOCAL_STORAGE, key, item);
3442
}
3543
}
3644
}

src/Blazor.Extensions.Storage/SessionStorage.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,38 @@ namespace Blazor.Extensions.Storage
77
{
88
public class SessionStorage : IStorage
99
{
10-
public Task<int> Length() => JSRuntime.Current.InvokeAsync<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.SESSION_STORAGE);
11-
public Task Clear() => JSRuntime.Current.InvokeAsync<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.SESSION_STORAGE);
10+
private readonly IJSRuntime runtime;
11+
12+
public Task<int> Length() => this.runtime.InvokeAsync<int>(MethodNames.LENGTH_METHOD, StorageTypeNames.SESSION_STORAGE);
13+
14+
public Task Clear() => this.runtime.InvokeAsync<object>(MethodNames.CLEAR_METHOD, StorageTypeNames.SESSION_STORAGE);
15+
16+
public SessionStorage(IJSRuntime runtime)
17+
{
18+
this.runtime = runtime;
19+
}
1220

1321
public Task<TItem> GetItem<TItem>(string key)
1422
{
1523
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
1624

17-
return JSRuntime.Current.InvokeAsync<TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key);
25+
return this.runtime.InvokeAsync<TItem>(MethodNames.GET_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key);
1826
}
1927

20-
public Task<string> Key(int index) => JSRuntime.Current.InvokeAsync<string>(MethodNames.KEY_METHOD, StorageTypeNames.SESSION_STORAGE, index);
28+
public Task<string> Key(int index) => this.runtime.InvokeAsync<string>(MethodNames.KEY_METHOD, StorageTypeNames.SESSION_STORAGE, index);
2129

2230
public Task RemoveItem(string key)
2331
{
2432
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
2533

26-
return JSRuntime.Current.InvokeAsync<object>(MethodNames.REMOVE_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key);
34+
return this.runtime.InvokeAsync<object>(MethodNames.REMOVE_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key);
2735
}
2836

2937
public Task SetItem<TItem>(string key, TItem item)
3038
{
3139
if (string.IsNullOrWhiteSpace(key)) throw new ArgumentNullException(nameof(key));
3240

33-
return JSRuntime.Current.InvokeAsync<TItem>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key, item);
41+
return this.runtime.InvokeAsync<TItem>(MethodNames.SET_ITEM_METHOD, StorageTypeNames.SESSION_STORAGE, key, item);
3442
}
3543
}
3644
}
File renamed without changes.

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<RunCommand>dotnet</RunCommand>
5-
<RunArguments>blazor serve</RunArguments>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>7.3</LangVersion>
6+
<RazorLangVersion>3.0</RazorLangVersion>
67
</PropertyGroup>
78

89
<ItemGroup>
9-
<PackageReference Include="Blazor.Extensions.Logging" Version="0.1.8" />
10-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
11-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
12-
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.7.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
11+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

test/Blazor.Extensions.Storage.Test/Interop/InteropStorage.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,21 @@ namespace Blazor.Extensions.Storage.Test.Interop
88
/// </summary>
99
public class InteropStorage
1010
{
11+
private readonly IJSRuntime runtime;
12+
13+
public InteropStorage(IJSRuntime runtime)
14+
{
15+
this.runtime = runtime;
16+
}
17+
1118
/// <summary>
1219
/// Returns a session storage value.
1320
/// </summary>
1421
/// <param name="key">Key associated with stroed value.</param>
1522
/// <returns>Task that returns the stored value as a string.</returns>
1623
public async Task<string> GetSessionStorage(string key)
1724
{
18-
return await JSRuntime.Current.InvokeAsync<string>(
25+
return await this.runtime.InvokeAsync<string>(
1926
"getSessionStorage",
2027
key
2128
);
@@ -28,7 +35,7 @@ public async Task<string> GetSessionStorage(string key)
2835
/// <returns>Task that returns the stored value as a string.</returns>
2936
public async Task<string> GetLocalStorage(string key)
3037
{
31-
return await JSRuntime.Current.InvokeAsync<string>(
38+
return await this.runtime.InvokeAsync<string>(
3239
"getLocalStorage",
3340
key
3441
);

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

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)