Skip to content

Commit 748cf9d

Browse files
committed
small fixes
1 parent a37054d commit 748cf9d

File tree

10 files changed

+17
-9
lines changed

10 files changed

+17
-9
lines changed

src/Desktop/MaSchoeller.Extensions.Desktop.Sample1/Controllers/Page1Controller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MaSchoeller.Extensions.Desktop.Mvvm;
1+
using MaSchoeller.Extensions.Desktop.Helpers;
22
using MaSchoeller.Extensions.Desktop.Sample1.ViewModels;
33
using System;
44
using System.Collections.Generic;

src/Desktop/MaSchoeller.Extensions.Desktop.Sample1/Controllers/Page2Controller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MaSchoeller.Extensions.Desktop.Mvvm;
1+
using MaSchoeller.Extensions.Desktop.Helpers;
22
using MaSchoeller.Extensions.Desktop.Sample1.ViewModels;
33
using System;
44
using System.Collections.Generic;

src/Desktop/MaSchoeller.Extensions.Desktop/Abstracts/IController.cs

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

55
namespace MaSchoeller.Extensions.Desktop.Abstracts
66
{
7-
public interface IController : IRoutable
7+
public interface IController
88
{
99
public object Initialize();
1010
}

src/Desktop/MaSchoeller.Extensions.Desktop/Abstracts/INavigationServiceBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Text;
5+
using System.Windows;
56
using System.Windows.Controls;
67

78
namespace MaSchoeller.Extensions.Desktop.Abstracts

src/Desktop/MaSchoeller.Extensions.Desktop/Mvvm/ControllerBase.cs renamed to src/Desktop/MaSchoeller.Extensions.Desktop/Helpers/ControllerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using System.Text;
66

7-
namespace MaSchoeller.Extensions.Desktop.Mvvm
7+
namespace MaSchoeller.Extensions.Desktop.Helpers
88
{
99
public abstract class ControllerBase : RoutableBase, IController
1010
{

src/Desktop/MaSchoeller.Extensions.Desktop/Helpers/RoutableBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Text;
66
using System.Threading.Tasks;
7+
using System.Windows;
78

89
namespace MaSchoeller.Extensions.Desktop.Helpers
910
{

src/Desktop/MaSchoeller.Extensions.Desktop/Internals/Hosting/DesktopContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ IHostApplicationLifetime lifetime
2626

2727
public bool IsRunning { get; set; }
2828

29-
public Application? WpfApplication { get; set; }
29+
public Application WpfApplication { get; set; }
3030

31-
public Dispatcher? Dispatcher => WpfApplication?.Dispatcher;
31+
public Dispatcher Dispatcher => WpfApplication?.Dispatcher!;
3232
}
3333
}

src/Desktop/MaSchoeller.Extensions.Desktop/Internals/Mvvmc/MvvmcNavigationService.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ public async Task<bool> TryNavigateToAsync(string route)
7777
{
7878
throw new InvalidCastException($"The Controller '{_routes[route].Controller.GetType().FullName}' does not implement '{typeof(IController).FullName}', can't able to navigate to this object, change from MVVMC to MVVM if you want only a ViewModel");
7979
}
80+
if (!(controller is IRoutable routable))
81+
{
82+
throw new InvalidCastException($"The Controller '{_routes[route].Controller.GetType().FullName}' does not implement '{typeof(IRoutable).FullName}', can't able to navigate to this object");
83+
}
8084
if (!(ActivatorUtilities.CreateInstance(_currentServiceScope.ServiceProvider, _routes[route].View) is Page view))
8185
{
8286
throw new InvalidCastException($"The related view '{_routes[route].View.GetType().FullName}' does not inheritance from '{typeof(Page).FullName}', can't able to navigate to this page..");
8387
}
84-
var canEnter = await controller.CanEnterRouteAsync();
88+
var canEnter = await routable.CanEnterRouteAsync();
8589
if (!canEnter)
8690
{
8791
return false;
@@ -91,7 +95,7 @@ public async Task<bool> TryNavigateToAsync(string route)
9195
if (succeeded)
9296
{
9397
await (CurrentRoute?.LeaveAsync() ?? Task.CompletedTask);
94-
CurrentRoute = controller;
98+
CurrentRoute = routable;
9599
_currentRouteName = route;
96100
await CurrentRoute.EnterAsync();
97101
Navigated?.Invoke(this, new NavigationEventArgs(route));

src/Desktop/MaSchoeller.Extensions.Desktop/Internals/Mvvmc/MvvmcNavigationServiceBuilder.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
using System.Collections.Generic;
66
using System.Drawing;
77
using System.Text;
8+
using System.Windows;
89
using System.Windows.Controls;
910

1011
namespace MaSchoeller.Extensions.Desktop.Internals.Mvvmc
1112
{
1213
internal class MvvmcNavigationServiceBuilder : INavigationServiceBuilder
1314
{
1415
private readonly IDictionary<string, (Type ViewModel, Type Page)> _bindings;
16+
private readonly IDictionary<string, (Type ViewModel, Type Page)> _controller;
1517
private Action<IServiceCollection>? _dependencies;
1618

1719
public MvvmcNavigationServiceBuilder()

src/Desktop/MaSchoeller.Extensions.Desktop/MaSchoeller.Extensions.Desktop.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<LangVersion>8</LangVersion>
88
<PackageId>MaSchoeller.Extensions.Desktop</PackageId>
9-
<Version>0.1.6</Version>
9+
<Version>0.2.0</Version>
1010
<Authors>Marvin Schoeller</Authors>
1111
<Company>MaSchoeller</Company>
1212
<PackageProjectUrl>https://github.com/maSchoeller/DotnetExtensions</PackageProjectUrl>

0 commit comments

Comments
 (0)