mirror of https://github.com/AMT-Cheif/Stylet.git
Deprecate CanClose
There's no nice way to make it work alongside CanCloseAsync when you're in a conductor hierarchy. There will always be difference between how CanClose and CanCloseAsync behave when there are children which need to be interrogated as well, and that's confusing.
This commit is contained in:
parent
35c1b3320f
commit
6cd4546a80
|
@ -56,7 +56,10 @@ namespace Stylet
|
|||
/// <returns>Task indicating whether this can be closed</returns>
|
||||
public override Task<bool> CanCloseAsync()
|
||||
{
|
||||
// Temporarily, until we remove CanClose
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (!this.CanClose())
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
return Task.FromResult(false);
|
||||
return this.CanCloseItem(this.ActiveItem);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,10 @@ namespace Stylet
|
|||
/// <returns>A Task indicating whether this conductor can close</returns>
|
||||
public override Task<bool> CanCloseAsync()
|
||||
{
|
||||
// Temporarily, until we remove CanClose
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (!this.CanClose())
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
return Task.FromResult(false);
|
||||
return this.CanAllItemsCloseAsync(this.items);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,10 @@ namespace Stylet
|
|||
/// <returns>A task indicating whether this conductor can close</returns>
|
||||
public override Task<bool> CanCloseAsync()
|
||||
{
|
||||
// Temporarily, until we remove CanClose
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (!this.CanClose())
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
return Task.FromResult(false);
|
||||
return this.CanAllItemsCloseAsync(this.history.Concat(new[] { this.ActiveItem }));
|
||||
}
|
||||
|
|
|
@ -170,7 +170,10 @@ namespace Stylet
|
|||
/// <returns>A task indicating whether this conductor can close</returns>
|
||||
public override Task<bool> CanCloseAsync()
|
||||
{
|
||||
// Temporarily, until we remove CanClose
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
if (!this.CanClose())
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
return Task.FromResult(false);
|
||||
return this.CanAllItemsCloseAsync(this.items);
|
||||
}
|
||||
|
|
|
@ -257,13 +257,17 @@ namespace Stylet
|
|||
/// <returns>A task returning true (can close) or false (can't close)</returns>
|
||||
public virtual Task<bool> CanCloseAsync()
|
||||
{
|
||||
// Temporary, before we remove CanClose()
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
return Task.FromResult(this.CanClose());
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronous alternative to CanClose
|
||||
/// </summary>
|
||||
/// <returns>True if this screen can close, or false otherwise</returns>
|
||||
[Obsolete("This method is deprecated, please use CanCloseAsync() instead")]
|
||||
protected virtual bool CanClose()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -15,9 +15,9 @@ namespace StyletUnitTests
|
|||
private class MyConductor : Conductor<IScreen>.Collection.AllActive
|
||||
{
|
||||
public bool CanCloseValue = true;
|
||||
protected override bool CanClose()
|
||||
public override async Task<bool> CanCloseAsync()
|
||||
{
|
||||
return this.CanCloseValue;
|
||||
return this.CanCloseValue && await base.CanCloseAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ namespace StyletUnitTests
|
|||
private class MyConductor : Conductor<IScreen>.StackNavigation
|
||||
{
|
||||
public bool CanCloseValue = true;
|
||||
protected override bool CanClose()
|
||||
public override async Task<bool> CanCloseAsync()
|
||||
{
|
||||
return this.CanCloseValue;
|
||||
return this.CanCloseValue && await base.CanCloseAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ namespace StyletUnitTests
|
|||
private class MyConductor : Conductor<IScreen>.Collection.OneActive
|
||||
{
|
||||
public bool CanCloseValue = true;
|
||||
protected override bool CanClose()
|
||||
public override async Task<bool> CanCloseAsync()
|
||||
{
|
||||
return this.CanCloseValue;
|
||||
return this.CanCloseValue && await base.CanCloseAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ namespace StyletUnitTests
|
|||
private class MyConductor : Conductor<IScreen>
|
||||
{
|
||||
public bool CanCloseValue = true;
|
||||
protected override bool CanClose()
|
||||
public async override Task<bool> CanCloseAsync()
|
||||
{
|
||||
return this.CanCloseValue;
|
||||
return this.CanCloseValue && await base.CanCloseAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using NUnit.Framework;
|
|||
using Stylet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace StyletUnitTests
|
||||
|
@ -65,9 +66,9 @@ namespace StyletUnitTests
|
|||
}
|
||||
|
||||
public bool? CanCloseResult = null;
|
||||
protected override bool CanClose()
|
||||
public override Task<bool> CanCloseAsync()
|
||||
{
|
||||
return this.CanCloseResult == null ? base.CanClose() : this.CanCloseResult.Value;
|
||||
return this.CanCloseResult == null ? base.CanCloseAsync() : Task.FromResult(this.CanCloseResult.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue