Skip to content

Commit

Permalink
feat: Update to .Net Core preview6
Browse files Browse the repository at this point in the history
  • Loading branch information
dworthen committed Jun 19, 2019
1 parent b4f1b55 commit 6494fc3
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 100 deletions.
16 changes: 8 additions & 8 deletions BlazorRealm.sln
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2026
# Visual Studio Version 16
VisualStudioVersion = 16.0.28917.182
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorRealm", "src\BlazorRealm\BlazorRealm.csproj", "{E3C73603-90EF-472B-9076-043650A367E9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorStandAlone", "examples\BlazorStandAlone\BlazorStandAlone.csproj", "{B822325A-ED72-44FE-8721-3268C96C8B88}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorRealmAsync", "src\BlazorRealmAsync\BlazorRealmAsync.csproj", "{1BD0F7C1-0DD8-4600-9218-7728D6CE8D7F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorRealmReduxDevTools", "src\BlazorRealmReduxDevTools\BlazorRealmReduxDevTools.csproj", "{978D2FCB-A530-485D-A733-4C42E30FF38F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorClientApp", "examples\BlazorClientApp\BlazorClientApp.csproj", "{03D3D602-4271-42D0-9DEF-FC54F392E894}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,10 +21,6 @@ Global
{E3C73603-90EF-472B-9076-043650A367E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3C73603-90EF-472B-9076-043650A367E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3C73603-90EF-472B-9076-043650A367E9}.Release|Any CPU.Build.0 = Release|Any CPU
{B822325A-ED72-44FE-8721-3268C96C8B88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B822325A-ED72-44FE-8721-3268C96C8B88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B822325A-ED72-44FE-8721-3268C96C8B88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B822325A-ED72-44FE-8721-3268C96C8B88}.Release|Any CPU.Build.0 = Release|Any CPU
{1BD0F7C1-0DD8-4600-9218-7728D6CE8D7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BD0F7C1-0DD8-4600-9218-7728D6CE8D7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BD0F7C1-0DD8-4600-9218-7728D6CE8D7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -33,6 +29,10 @@ Global
{978D2FCB-A530-485D-A733-4C42E30FF38F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{978D2FCB-A530-485D-A733-4C42E30FF38F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{978D2FCB-A530-485D-A733-4C42E30FF38F}.Release|Any CPU.Build.0 = Release|Any CPU
{03D3D602-4271-42D0-9DEF-FC54F392E894}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03D3D602-4271-42D0-9DEF-FC54F392E894}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03D3D602-4271-42D0-9DEF-FC54F392E894}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03D3D602-4271-42D0-9DEF-FC54F392E894}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
23 changes: 9 additions & 14 deletions src/BlazorRealm/BlazorRealm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,22 @@
<RepositoryUrl>https://github.com/dworthen/BlazorRealm</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageTags>Blazor;Redux;State Management;Realm</PackageTags>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
</ItemGroup>

<ItemGroup>
<BlazorGenerate Remove="_ViewImports.cshtml" />
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<Compile Remove="RealmMiddlewareBuilder.cs" />
</ItemGroup>

<ItemGroup>
<Content Remove="_ViewImports.cshtml" />
</ItemGroup>

<ItemGroup>
<None Include="_ViewImports.cshtml" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/BlazorRealm/Extensions/IServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ public static Store<TState> AddRealmStore<TState>(this IServiceCollection servic
{
Store<TState> store = new Store<TState>(initialState, rootReducer);
services.AddSingleton<Store<TState>>(store);
IServiceProvider serviceProvider = services.BuildServiceProvider();
IStoreBuilder<TState> builder = new StoreBuilder<TState>(serviceProvider);
services.AddSingleton<IStoreBuilder<TState>>(builder);
//IServiceProvider serviceProvider = services.BuildServiceProvider();
//IStoreBuilder<TState> builder = new StoreBuilder<TState>(serviceProvider);
services.AddSingleton<IStoreBuilder<TState>, StoreBuilder<TState>>(/*builder*/);
return store;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/BlazorRealm/RealmComponent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Blazor.Components;
using Microsoft.AspNetCore.Components;
using System;

namespace Blazor.Realm
{
public class RealmComponent<TState> : BlazorComponent, IDisposable
public class RealmComponent<TState> : ComponentBase, IDisposable
{
[Inject]
public Store<TState> Store { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@ComponentTemplate(Store)


@functions {
@code {

[Inject]
private Store<TState> Store { get; set; }
Expand All @@ -29,7 +29,7 @@
protected virtual void OnChangeHandler(object sender, EventArgs e)
{
State = Store.GetState();
StateHasChanged();
this.StateHasChanged();
}

}
3 changes: 2 additions & 1 deletion src/BlazorRealm/Store.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.JSInterop;
using System;
using System.Text.Json.Serialization;

namespace Blazor.Realm
{
Expand Down Expand Up @@ -29,7 +30,7 @@ public TState GetState()
{
try
{
return Json.Deserialize<TState>(Json.Serialize(State));
return JsonSerializer.Parse<TState>(JsonSerializer.ToString<TState>(State));
} catch (Exception e)
{
return State;
Expand Down
1 change: 0 additions & 1 deletion src/BlazorRealm/_ViewImports.cshtml

This file was deleted.

23 changes: 9 additions & 14 deletions src/BlazorRealmAsync/BlazorRealmAsync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,18 @@
<PackageTags>Blazor;Redux;State Management;Realm;Middleware;Async</PackageTags>
<RepositoryUrl>https://github.com/dworthen/BlazorRealm</RepositoryUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
</ItemGroup>

<ItemGroup>
<BlazorGenerate Remove="_ViewImports.cshtml" />
</ItemGroup>

<ItemGroup>
<Content Remove="_ViewImports.cshtml" />
</ItemGroup>

<ItemGroup>
<None Include="_ViewImports.cshtml" />
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
</ItemGroup>

<Choose>
Expand Down
1 change: 0 additions & 1 deletion src/BlazorRealmAsync/_ViewImports.cshtml

This file was deleted.

21 changes: 11 additions & 10 deletions src/BlazorRealmReduxDevTools/BlazorRealmReduxDevTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<RepositoryType>Git</RepositoryType>
<PackageTags>Blazor;Redux;State Management;Realm;Middleware;Dev Tools;</PackageTags>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<RazorLangVersion>3.0</RazorLangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>

<ItemGroup>
Expand All @@ -27,16 +33,11 @@
</ItemGroup>

<ItemGroup>
<Content Remove="_ViewImports.cshtml" />
</ItemGroup>

<ItemGroup>
<None Include="_ViewImports.cshtml" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.7.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
</ItemGroup>

<Choose>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;

namespace Blazor.Realm.ReduxDevTools.Extensions
{
public static class IServiceCollectionExtensions
{
public static IServiceCollection AddRealmReduxDevToolServices(this IServiceCollection services)
{
services.AddSingleton<ReduxDevToolsInterop>();
return services;
}
}
}
72 changes: 57 additions & 15 deletions src/BlazorRealmReduxDevTools/HandleReduxDevTools.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
using Microsoft.AspNetCore.Blazor.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Primitives;
using Microsoft.AspNetCore.Http.Extensions;
using System.Linq;
using Microsoft.AspNetCore.Components.Routing;
using System.Text.Json.Serialization;

namespace Blazor.Realm.ReduxDevTools
{
Expand All @@ -13,6 +20,7 @@ public class HandleReduxDevTools<TState>
private readonly Type[] ActionsToIgnore;
private readonly Store<TState> Store;
private readonly Dispatcher<TState> Next;
private readonly ReduxDevToolsInterop reduxDevToolsInterop;

public HandleReduxDevTools(Store<TState> store, Dispatcher<TState> next, IServiceProvider serviceProvider) : this(store, next, serviceProvider, new Type[] { })
{
Expand All @@ -26,27 +34,57 @@ public HandleReduxDevTools(Store<TState> store, Dispatcher<TState> next, IServic
ServiceProvider = serviceProvider;
ActionsToIgnore = actionsToIgnore ?? new Type[] { };
UriHelper = ServiceProvider.GetService(typeof(IUriHelper)) as IUriHelper;
//IJSRuntime JSRuntime = ServiceProvider.GetService<IJSRuntime>();
reduxDevToolsInterop = ServiceProvider.GetService<ReduxDevToolsInterop>();
//reduxDevToolsInterop = new ReduxDevToolsInterop(JSRuntime);
TState state = store.GetState();
History.Add(new Tuple<string, string>(UriHelper.GetAbsoluteUri(), Json.Serialize(state)));
History.Add(new Tuple<string, string>(UriHelper.GetAbsoluteUri(), JsonSerializer.ToString<TState>(state)));

ReduxDevToolsInterop.Connect();
ReduxDevToolsInterop.Init(state);
ReduxDevToolsInterop.MessageReceived += (object sender, MessageEventArgs eventArgs) =>
reduxDevToolsInterop.Connect();
reduxDevToolsInterop.Init(state);

UriHelper.OnLocationChanged += (object s, LocationChangedEventArgs uri) =>
{
Dictionary<string, StringValues> queryParams = QueryHelpers.ParseQuery(new Uri(UriHelper.GetAbsoluteUri()).Query);
if(!queryParams.ContainsKey("RealmReduxDevToolsNavigation"))
{
TState State = store.GetState();
History.Add(new Tuple<string, string>(UriHelper.GetAbsoluteUri(), JsonSerializer.ToString<TState>(state)));
reduxDevToolsInterop.Send(new RealmReduxDevToolsUriChanged(), State);
}
};

ReduxDevToolsInterop.MessageReceived += (object sender, Message eventArgs) =>
{
if(eventArgs.Message.Payload?.Type == "JUMP_TO_STATE" || eventArgs.Message.Payload?.Type == "JUMP_TO_ACTION")
if (eventArgs.Payload?.Type == "JUMP_TO_STATE" || eventArgs.Payload?.Type == "JUMP_TO_ACTION")
{
int index = eventArgs.Message.Payload.Type == "JUMP_TO_STATE"
? eventArgs.Message.Payload.Index
: eventArgs.Message.Payload.ActionId;
int index = eventArgs.Payload.Type == "JUMP_TO_STATE"
? eventArgs.Payload.Index
: eventArgs.Payload.ActionId;
Tuple<string, string> desiredState = History[index];
store.Dispatch(new RealmReduxDevToolsAppState<TState>(Json.Deserialize<TState>(desiredState.Item2)));
if(desiredState.Item1 != UriHelper.GetAbsoluteUri())
store.Dispatch(new RealmReduxDevToolsAppState<TState>(JsonSerializer.Parse<TState>(desiredState.Item2)));
if (desiredState.Item1 != UriHelper.GetAbsoluteUri())
{
UriHelper.NavigateTo(desiredState.Item1);
UriBuilder uri = new UriBuilder(desiredState.Item1);
//Dictionary<string, StringValues> query = QueryHelpers.ParseNullableQuery(uri.Query);
//query.Add("RealmReduxDevToolsNavigation", "true");
//uri.Query = QueryHelpers.
List<KeyValuePair<string, string>> query = QueryHelpers
.ParseQuery(uri.Query)
.SelectMany(x => x.Value, (col, value) => new KeyValuePair<string, string>(col.Key, value))
.ToList();
QueryBuilder qb = new QueryBuilder(query);
qb.Add("RealmReduxDevToolsNavigation", "true");

//string newUri = QueryHelpers.AddQueryString(desiredState.Item1, "RealmReduxDevToolsNavigation", "true");
uri.Query = qb.ToQueryString().Value;
string newUri = uri.ToString();

UriHelper.NavigateTo(newUri);
}
}
};
ReduxDevToolsInterop.Subscribe();
reduxDevToolsInterop.Subscribe();
}

public TState Invoke(IRealmAction action)
Expand All @@ -59,8 +97,8 @@ public TState Invoke(IRealmAction action)
TState nextState = Next(action);
if (nextState != null && Array.IndexOf(ActionsToIgnore, action.GetType()) == -1)
{
History.Add(new Tuple<string, string>(UriHelper.GetAbsoluteUri(), Json.Serialize(nextState)));
ReduxDevToolsInterop.Send(action, nextState);
History.Add(new Tuple<string, string>(UriHelper.GetAbsoluteUri(), JsonSerializer.ToString<TState>(nextState)));
reduxDevToolsInterop.Send(action, nextState);
}
return nextState;
}
Expand All @@ -77,4 +115,8 @@ public RealmReduxDevToolsAppState(TState state)
State = state;
}
}

class RealmReduxDevToolsUriChanged : IRealmAction
{
}
}
17 changes: 9 additions & 8 deletions src/BlazorRealmReduxDevTools/MessageEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using Microsoft.JSInterop;
using System;
using System.Text.Json.Serialization;

namespace Blazor.Realm.ReduxDevTools
{
public class MessageEventArgs: EventArgs
{
public Message Message { get; set; }
//public class MessageEventArgs: EventArgs
//{
// public Message Message { get; set; }

public MessageEventArgs(string message)
{
Message = Json.Deserialize<Message>(message);
}
// public MessageEventArgs(string message)
// {
// Message = JsonSerializer.Parse<Message>(message);
// }

}
//}

public class Message
{
Expand Down
Loading

0 comments on commit 6494fc3

Please sign in to comment.