Skip to content

Commit

Permalink
Merge pull request PrismLibrary#1779 from PrismLibrary/IInitialize
Browse files Browse the repository at this point in the history
[BREAKING] Implements IInitialize
  • Loading branch information
dansiegel authored Apr 25, 2019
2 parents a1d383d + d654987 commit ae667e7
Show file tree
Hide file tree
Showing 41 changed files with 288 additions and 141 deletions.
2 changes: 1 addition & 1 deletion Source/Prism.Tests/Prism.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
18 changes: 0 additions & 18 deletions Source/Prism/Navigation/INavigatedAwareAsync.cs

This file was deleted.

2 changes: 0 additions & 2 deletions Source/Prism/Prism.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
</ItemGroup>

<ItemGroup>
<Compile Condition=" '$(TargetFramework)' == 'net45' or '$(TargetFramework)' == 'netcoreapp3.0' " Remove="Navigation/**" />
<Compile Include="Navigation/IDestructible.cs" />
<Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="DryIoc.dll" Version="4.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion Source/Wpf/Prism.DryIoc.Wpf/Prism.DryIoc.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="4.0.0" />
<PackageReference Include="DryIoc.dll" Version="4.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
Expand Down
2 changes: 1 addition & 1 deletion Source/Wpf/Prism.Wpf.Tests/Prism.Wpf.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<Reference Include="System.Windows.Interactivity">
<HintPath>..\System.Windows.Interactivity.dll</HintPath>
</Reference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task PartialViewSupportsINavigationAwareInterfaces()
var layout = (StackLayout)page.Content;
var partialView = (PartialView)layout.Children.FirstOrDefault(c => c is PartialView);
var vm = (PartialViewModel)partialView.BindingContext;
Assert.Equal(1, vm.OnNavigatingToCalled);
Assert.Equal(1, vm.InitializeCalled);
Assert.Equal(1, vm.OnNavigatedToCalled);
Assert.Equal(0, vm.OnNavigatedFromCalled);
Assert.Equal("Test", vm.SomeText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Prism.DI.Forms.Tests.Mocks.ViewModels
{
public class PartialViewModel : BindableBase, INavigationAware
public class PartialViewModel : BindableBase, IInitialize, INavigationAware
{
private INavigationService _navigationService { get; }

Expand All @@ -23,7 +23,7 @@ public string SomeText

public DelegateCommand NavigateCommand { get; }

public int OnNavigatingToCalled { get; private set; }
public int InitializeCalled { get; private set; }

public int OnNavigatedToCalled { get; private set; }

Expand All @@ -34,10 +34,10 @@ private async void OnNavigateCommandExecuted()
await _navigationService.NavigateAsync("/AutowireView");
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
SomeText = parameters.GetValue<string>("text");
OnNavigatingToCalled++;
InitializeCalled++;
}

public void OnNavigatedTo(INavigationParameters parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Xamarin.Forms" Version="3.6.0.220655" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Xamarin.Forms" Version="3.6.0.344457" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="4.0.0" />
<PackageReference Include="DryIoc.dll" Version="4.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void Command_OrderOfExecution()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, commandParameter));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, commandParameter, 0));
Assert.True(executedCommand);
}

Expand All @@ -76,7 +76,7 @@ public void Command_Converter()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item, 0));
Assert.True(executedCommand);
}

Expand All @@ -99,7 +99,7 @@ public void Command_ConverterWithConverterParameter()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}

Expand All @@ -121,7 +121,7 @@ public void Command_ExecuteWithParameter()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}

Expand All @@ -143,7 +143,7 @@ public void Command_EventArgsParameterPath()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, item, 0));
Assert.True(executedCommand);
}

Expand Down Expand Up @@ -189,7 +189,7 @@ public void Command_EventArgsParameterPath_Nested_When_ChildIsNull()
};
var listView = new ListView();
listView.Behaviors.Add(behavior);
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null));
behavior.RaiseEvent(listView, new ItemTappedEventArgs(listView, null, 0));
Assert.True(executedCommand);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
{
public enum PageNavigationEvent
{
OnNavigatingTo,
OnInitialized,
OnInitializedAsync,
OnNavigatedFrom,
OnNavigatedTo,
Destroy
Expand Down
21 changes: 15 additions & 6 deletions Source/Xamarin/Prism.Forms.Tests/Mocks/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using System;
using System.Threading.Tasks;
using Prism.Mvvm;
using Prism.Navigation;

namespace Prism.Forms.Tests.Mocks.ViewModels
{
public class ViewModelBase : BindableBase, INavigationAware, IDestructible, IPageNavigationEventRecordable
public class ViewModelBase : BindableBase, IInitialize, IInitializeAsync, INavigationAware, IDestructible, IPageNavigationEventRecordable
{
public INavigationParameters NavigatedToParameters { get; private set; }
public INavigationParameters NavigatedFromParameters { get; private set; }
public PageNavigationEventRecorder PageNavigationEventRecorder { get; set; }

public bool OnNavigatedToCalled { get; private set; } = false;

public bool OnNavigatingdToCalled { get; private set; } = false;
public bool InitializeCalled { get; private set; } = false;

public bool InitializeAsyncCalled { get; private set; } = false;

public bool OnNavigatedFromCalled { get; private set; } = false;

Expand All @@ -32,11 +35,17 @@ public void OnNavigatedTo(INavigationParameters parameters)
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatedTo);
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
OnNavigatingdToCalled = true;
NavigatedToParameters = parameters;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
InitializeCalled = true;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}

public Task InitializeAsync(INavigationParameters parameters)
{
InitializeAsyncCalled = true;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitializedAsync);
return Task.CompletedTask;
}

public void Destroy()
Expand Down
18 changes: 13 additions & 5 deletions Source/Xamarin/Prism.Forms.Tests/Mocks/Views/ContentPageMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@

namespace Prism.Forms.Tests.Mocks.Views
{
public class ContentPageMock : ContentPage, INavigationAware, IConfirmNavigationAsync, IDestructible, IPageNavigationEventRecordable
public class ContentPageMock : ContentPage, IInitialize, IInitializeAsync, INavigationAware, IConfirmNavigationAsync, IDestructible, IPageNavigationEventRecordable
{
public PageNavigationEventRecorder PageNavigationEventRecorder { get; set; }
public bool OnNavigatedToCalled { get; private set; } = false;
public bool OnNavigatedFromCalled { get; private set; } = false;
public bool OnNavigatingToCalled { get; private set; } = false;
public bool InitializeCalled { get; private set; } = false;
public bool InitializeAsyncCalled { get; private set; } = false;

public bool OnConfirmNavigationCalled { get; private set; } = false;

Expand Down Expand Up @@ -41,10 +42,17 @@ public void OnNavigatedTo(INavigationParameters parameters)
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatedTo);
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
OnNavigatingToCalled = true;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
InitializeCalled = true;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}

public Task InitializeAsync(INavigationParameters parameters)
{
InitializeAsyncCalled = true;
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitializedAsync);
return Task.CompletedTask;
}

public Task<bool> CanNavigateAsync(INavigationParameters parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Prism.Forms.Tests.Mocks.Views
{
public class NavigationPageMock : NavigationPage, IDestructible, IPageNavigationEventRecordable, INavigationPageOptions, INavigationAware
public class NavigationPageMock : NavigationPage, IDestructible, IPageNavigationEventRecordable, INavigationPageOptions, IInitialize, INavigationAware
{
public bool DestroyCalled { get; private set; } = false;
public PageNavigationEventRecorder PageNavigationEventRecorder { get; set; }
Expand Down Expand Up @@ -43,9 +43,9 @@ public void OnNavigatedTo(INavigationParameters parameters)
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatedTo);
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}
}

Expand Down Expand Up @@ -77,7 +77,7 @@ public void OnNavigatedTo(INavigationParameters parameters)

public void OnNavigatingTo(INavigationParameters parameters)
{
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}

public Task<bool> CanNavigateAsync(INavigationParameters parameters)
Expand Down
6 changes: 3 additions & 3 deletions Source/Xamarin/Prism.Forms.Tests/Mocks/Views/PageMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Prism.Forms.Tests.Mocks.Views
{
public class PageMock : Page, INavigationAware, IConfirmNavigationAsync, IDestructible, IPageNavigationEventRecordable
public class PageMock : Page, IInitialize, INavigationAware, IConfirmNavigationAsync, IDestructible, IPageNavigationEventRecordable
{
public PageNavigationEventRecorder PageNavigationEventRecorder { get; set; }

Expand All @@ -29,9 +29,9 @@ public void OnNavigatedTo(INavigationParameters parameters)
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatedTo);
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}

public Task<bool> CanNavigateAsync(INavigationParameters parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Prism.Forms.Tests.Mocks.Views
{
public class TabbedPageMock : TabbedPage, IDestructible, INavigationAware, IPageNavigationEventRecordable
public class TabbedPageMock : TabbedPage, IDestructible, IInitialize, INavigationAware, IPageNavigationEventRecordable
{
public bool DestroyCalled { get; private set; } = false;
public PageNavigationEventRecorder PageNavigationEventRecorder { get; set; }
Expand Down Expand Up @@ -48,9 +48,9 @@ public void OnNavigatedTo(INavigationParameters parameters)
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatedTo);
}

public void OnNavigatingTo(INavigationParameters parameters)
public void Initialize(INavigationParameters parameters)
{
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnNavigatingTo);
PageNavigationEventRecorder?.Record(this, PageNavigationEvent.OnInitialized);
}
}
}
Loading

0 comments on commit ae667e7

Please sign in to comment.