Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jspuij/Cortex.Net
Browse files Browse the repository at this point in the history
  • Loading branch information
jspuij committed Nov 14, 2019
2 parents ea49a2f + 94b5f50 commit efc7729
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 20 deletions.
16 changes: 15 additions & 1 deletion samples/Cortex.Net.BlazorTodo/App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<Router AppAssembly="@typeof(Program).Assembly">
@inject NavigationManager NavigationManager

<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
Expand All @@ -8,3 +10,15 @@
</LayoutView>
</NotFound>
</Router>

@code
{
/// <summary>
/// Navigates to the default hash.
/// </summary>
protected override void OnInitialized()
{
base.OnInitialized();
this.NavigationManager.NavigateTo("#/");
}
}
15 changes: 13 additions & 2 deletions samples/Cortex.Net.BlazorTodo/Components/TodoEntry.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,28 @@

@code {

/// <summary>
/// Gets or sets the Title.
/// </summary>
public string Title { get; set; }

/// <summary>
/// Handles the key down event.
/// </summary>
/// <param name="args">The keyboard event arguments.</param>
public void HandleKeyDown(KeyboardEventArgs args)
{
if (args.Key != "Enter")
{
return;
}

this.TodoStore.AddTodo(this.Title.Trim());
this.Title = "";
var val = this.Title?.Trim();

if (!string.IsNullOrEmpty(val))
{
this.TodoStore.AddTodo(val);
this.Title = "";
}
}
}
6 changes: 3 additions & 3 deletions samples/Cortex.Net.BlazorTodo/Components/TodoFooter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
<!-- Remove this if you don't implement routing -->
<ul class="filters">
<li>
<a class="selected" href="#/">All</a>
<NavLink href="#/" ActiveClass="selected" Match="NavLinkMatch.All">All</NavLink>
</li>
<li>
<a href="#/active">Active</a>
<NavLink href="#/active" ActiveClass="selected" Match="NavLinkMatch.All">Active</NavLink>
</li>
<li>
<a href="#/completed">Completed</a>
<NavLink href="#/completed" ActiveClass="selected" Match="NavLinkMatch.All">Completed</NavLink>
</li>
</ul>
@if (this.TodoStore.CompletedCount > 0)
Expand Down
1 change: 1 addition & 0 deletions samples/Cortex.Net.BlazorTodo/Components/TodoItem.razor
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
/// Destroys the todo item.
/// </summary>
/// <param name="mouseEventArgs">The mouse event args.</param>
[Action]
void Destroy(MouseEventArgs mouseEventArgs)
{
this.Todo.Destroy();
Expand Down
6 changes: 3 additions & 3 deletions samples/Cortex.Net.BlazorTodo/Components/TodoOverview.razor
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
<!-- This section should be hidden by default and shown when there are todos -->
<section class="main">
<input id="toggle-all" class="toggle-all" type="checkbox" @onchange="ToggleAll" checked="@this.TodoStore.ActiveCount == 0">
<input id="toggle-all" class="toggle-all" type="checkbox" @onchange="ToggleAll" checked="@(this.TodoStore.ActiveCount == 0)" />
<label for="toggle-all">Mark all as complete</label>
<ul class="todo-list">
<!-- These are here just to show the structure of the list items -->
Expand All @@ -23,8 +23,8 @@
</section>
}

@code {

@code
{
/// <summary>
/// Gets the visible Todos.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion samples/Cortex.Net.BlazorTodo/Models/Todo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void Toggle()
/// <summary>
/// Destroys this todo by removing it from the Store.
/// </summary>
[Action]
public void Destroy()
{
this.Store.Todos.Remove(this);
Expand Down
53 changes: 52 additions & 1 deletion samples/Cortex.Net.BlazorTodo/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
@page "/"
@using Cortex.Net.Api
@using Cortex.Net.Blazor
@using Cortex.Net.BlazorTodo.Stores
@implements IDisposable

@page "/"

@attribute [Observer]

@inject ViewStore ViewStore
@inject NavigationManager NavigationManager

<TodoOverview />

@code
{
/// <summary>
/// Bind to the Navigation changed event. This is necessary because of the Anchor Urls in the TodoMVC sample.
/// </summary>
protected override void OnInitialized()
{
NavigationManager.LocationChanged += OnLocationChanged;
}

/// <summary>
/// Handle the OnLocationChanged event.
/// </summary>
/// <param name="sender"></param>
/// <param name="eventArgs"></param>
[Action]
void OnLocationChanged(object sender, LocationChangedEventArgs eventArgs)
{
switch (NavigationManager.ToBaseRelativePath(eventArgs.Location))
{
case "#/active":
this.ViewStore.TodoFilter = TodoFilter.Active;
break;
case "#/completed":
this.ViewStore.TodoFilter = TodoFilter.Completed;
break;
case "#/":
this.ViewStore.TodoFilter = TodoFilter.All;
break;
}
}

/// <summary>
/// Release the eventhandler from the Navigation manager.
/// </summary>
public virtual void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
}
6 changes: 0 additions & 6 deletions src/Cortex.Net.Fody/BlazorObserverWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,6 @@ private void WeaveBuildRenderTreeMethod(MethodDefinition buildRenderTreeMethod,
processor.Create(OpCodes.Ldc_I4_1),
processor.Create(OpCodes.Bne_Un_S, originalStart),

// write the name of the function to the console.
processor.Create(OpCodes.Ldarg_0),
processor.Create(OpCodes.Call, module.ImportReference(getTypeReference)),
processor.Create(OpCodes.Callvirt, module.ImportReference(getFullNameReference)),
processor.Create(OpCodes.Call, module.ImportReference(writeLineReference)),

// load the field where the action delegate is stored.
processor.Create(OpCodes.Ldarg_0),
processor.Create(OpCodes.Ldfld, observerObjectDefinition),
Expand Down
2 changes: 1 addition & 1 deletion src/Cortex.Net.Fody/ComputedWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ private void EmitComputedMemberAdd(
processor.Emit(OpCodes.Dup);
processor.Emit(OpCodes.Ldarg_0);
processor.Emit(OpCodes.Ldftn, setMethodDefinition);
processor.Emit(OpCodes.Newobj, functionTypeConstructorReference);
processor.Emit(OpCodes.Newobj, actionTypeConstructorReference);
processor.Emit(OpCodes.Callvirt, setSetterReference);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Cortext.Next.Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

namespace Cortext.Next.Playground
{
class Program
public class Program
{
static void Main(string[] args)
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Program start.")]
public static void Main(string[] args)
{
var sharedState = new SharedState(new CortexConfiguration()
{
Expand Down

0 comments on commit efc7729

Please sign in to comment.