Deprecate Screen.State, in favour of Screen.ScreenState

It's confusing to have a property called 'State'
This commit is contained in:
Antony Male 2016-08-26 11:25:42 +01:00
parent 6cd4546a80
commit 3916c825ae
3 changed files with 26 additions and 10 deletions

View File

@ -57,7 +57,7 @@ namespace Stylet
/// <summary>
/// Gets the current state of the Screen
/// </summary>
ScreenState State { get; }
ScreenState ScreenState { get; }
/// <summary>
/// Gets a value indicating whether the current state is ScreenState.Active

View File

@ -48,17 +48,33 @@ namespace Stylet
#region IScreenState
private ScreenState _state = ScreenState.Deactivated;
private ScreenState _screenState = ScreenState.Deactivated;
/// <summary>
/// Gets or sets the current state of the Screen
/// </summary>
[Obsolete("State is deprecated, please use ScreenState instead")]
public virtual ScreenState State
{
get { return this._state; }
get { return this.ScreenState; }
protected set { this.ScreenState = value; }
}
/// <summary>
/// Gets or sets the current state of the Screen
/// </summary>
public virtual ScreenState ScreenState
{
get { return this._screenState; }
protected set
{
this.SetAndNotify(ref this._state, value);
if (this.SetAndNotify(ref this._screenState, value))
{
// Temporary, until we remove 'State'
#pragma warning disable CS0618 // Type or member is obsolete
this.NotifyOfPropertyChange(() => this.State);
#pragma warning restore CS0618 // Type or member is obsolete
}
this.NotifyOfPropertyChange(() => this.IsActive);
}
}
@ -68,7 +84,7 @@ namespace Stylet
/// </summary>
public bool IsActive
{
get { return this.State == ScreenState.Active; }
get { return this.ScreenState == ScreenState.Active; }
}
private bool haveActivated = false;
@ -127,11 +143,11 @@ namespace Stylet
/// <param name="changedHandler">Called if the transition occurs. Arguments are (newState, previousState)</param>
protected virtual void SetState(ScreenState newState, Action<ScreenState, ScreenState> changedHandler)
{
if (newState == this.State)
if (newState == this.ScreenState)
return;
var previousState = this.State;
this.State = newState;
var previousState = this.ScreenState;
this.ScreenState = newState;
this.logger.Info("Setting state from {0} to {1}", previousState, newState);
@ -180,7 +196,7 @@ namespace Stylet
void IScreenState.Close()
{
// Avoid going from Activated -> Closed without going via Deactivated
if (this.State != ScreenState.Closed)
if (this.ScreenState != ScreenState.Closed)
((IScreenState)this).Deactivate();
this.View = null;

View File

@ -101,7 +101,7 @@ namespace StyletUnitTests
[Test]
public void ScreenIsInitiallyDeactivated()
{
Assert.AreEqual(ScreenState.Deactivated, this.screen.State);
Assert.AreEqual(ScreenState.Deactivated, this.screen.ScreenState);
}
[Test]