Skip to content

Commit

Permalink
Removes all obsolete classes and methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpduda committed Nov 13, 2020
1 parent 433ff97 commit 6e9130c
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 229 deletions.
17 changes: 0 additions & 17 deletions source/UpbeatUI/ViewModel/IOpensUpbeatViewModels.cs

This file was deleted.

26 changes: 0 additions & 26 deletions source/UpbeatUI/ViewModel/IOpensViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,6 @@ namespace UpbeatUI.ViewModel
public interface IOpensViewModels

{
/// <summary>
/// Adds a new ViewModel to the <see cref="UpbeatStack"/> based on the <typeparamref name="TParameters"/> provided.
/// </summary>
/// <typeparam name="TParameters">The type of the parameters used to create the ViewModel.</typeparam>
/// <param name="parameters">The parameters used to create the ViewModel.</param>
[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
void OpenUpbeatViewModel<TParameters>(TParameters parameters);

/// <summary>
/// Adds a new ViewModel to the <see cref="UpbeatStack"/> based on the <typeparamref name="TParameters"/> provided and executes a callback after that ViewModel closes.
/// </summary>
/// <typeparam name="TParameters">The type of the parameters used to create the ViewModel.</typeparam>
/// <param name="parameters">The parameters used to create the ViewModel.</param>
/// <param name="closeCallback">A delegate for the <see cref="UpbeatStack"/> to execute after the ViewModel closes.</param>
[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
void OpenUpbeatViewModel<TParameters>(TParameters parameters, Action closedCallback);

/// <summary>
/// Adds a new ViewModel to the <see cref="UpbeatStack"/> based on the <typeparamref name="TParameters"/> provided and returns a <see cref="Task"/> that completes after the ViewModel closes.
/// </summary>
/// <typeparam name="TParameters">The type of the parameters used to create the ViewModel.</typeparam>
/// <param name="parameters">The parameters used to create the ViewModel.</param>
/// <returns>A <see cref="Task"/> that represents the created ViewModel being open</returns>
[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
Task OpenUpbeatViewModelAsync<TParameters>(TParameters parameters);

/// <summary>
/// Adds a new ViewModel to the <see cref="UpbeatStack"/> based on the <typeparamref name="TParameters"/> provided.
/// </summary>
Expand Down
18 changes: 1 addition & 17 deletions source/UpbeatUI/ViewModel/IUpbeatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ namespace UpbeatUI.ViewModel
/// <summary>
/// Provides methods for a ViewModel to interact with the <see cref="UpbeatStack"/> that it is a part of. <see cref="IUpbeatService"/> instancess are created by the <see cref="UpbeatStack"/> unique to each ViewModel, so do not share them.
/// </summary>
public interface IUpbeatService : IOpensViewModels, IOpensUpbeatViewModels
public interface IUpbeatService : IOpensViewModels
{
/// <summary>
/// Gets whether or not the ViewModel is the top item in the <see cref="UpbeatStack"/>, and thus active for the user.
/// </summary>
[Obsolete("Renamed to IsActiveViewModel. This property will be removed in UpbeatUI 3.0.")]
bool IsActiveUpbeatViewModel { get; }
bool IsActiveViewModel { get; }
/// <summary>
/// Gets whether or not the parent <see cref="UpbeatStack"/> is configured to update ViewModels on each rendering event.
Expand All @@ -29,20 +27,6 @@ public interface IUpbeatService : IOpensViewModels, IOpensUpbeatViewModels
/// </summary>
void Close();

/// <summary>
/// Gets the current string contents of the clipboard. This is a convenience method for assemblies that do not want to reference <see cref="System.Windows"/>.
/// </summary>
/// <returns>The current contents of the clipboard.</returns>
[Obsolete("This will be removed in UpbeatUI 3.0. Use another injected service instead.")]
string GetClipboard();

/// <summary>
/// Sets the string contents of the clipboard. This is a convenience method for assemblies that do not want to reference <see cref="System.Windows"/>.
/// </summary>
/// <param name="text">What to set the clipboard to.</param>
[Obsolete("This will be removed in UpbeatUI 3.0. Use another injected service instead.")]
void SetClipboard(string text);

/// <summary>
/// Sets the delegate that the containing <see cref="UpbeatStack"/> will call before closing this ViewModel (instead of closing it automatically). The delegate should return true if okay to close and false if the ViewModel needs to stay open.
/// </summary>
Expand Down
23 changes: 0 additions & 23 deletions source/UpbeatUI/ViewModel/IUpbeatViewModel.cs

This file was deleted.

21 changes: 0 additions & 21 deletions source/UpbeatUI/ViewModel/IUpdatableViewModel.cs

This file was deleted.

32 changes: 0 additions & 32 deletions source/UpbeatUI/ViewModel/UpbeatStack.UpbeatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
using System;
using System.Threading.Tasks;
using System.Windows;

namespace UpbeatUI.ViewModel
{
Expand All @@ -26,8 +25,6 @@ internal UpbeatService(bool updatesOnRender, Action<object, Action> childViewMod
ClosedCallback = closedCallback;
}

[Obsolete("Renamed to IsActiveViewModel. This property will be removed in UpbeatUI 3.0.")]
public bool IsActiveUpbeatViewModel => IsActiveViewModel;
public bool IsActiveViewModel => _isActiveViewModel();
public bool UpdatesOnRender { get; }
internal Action ClosedCallback { get; }
Expand All @@ -40,22 +37,6 @@ public void Close()
_deferrer(() => _closer());
}

[Obsolete("This will be removed in UpbeatUI 3.0. Use another injected service instead.")]
public string GetClipboard() =>
Clipboard.GetText();

[Obsolete("Renamed to OpenViewModel. This method will be removed in UpbeatUI 3.0.")]
public void OpenUpbeatViewModel<TParameters>(TParameters parameters) =>
OpenViewModel(parameters);

[Obsolete("Renamed to OpenViewModel. This method will be removed in UpbeatUI 3.0.")]
public void OpenUpbeatViewModel<TParameters>(TParameters parameters, Action closedCallback) =>
OpenViewModel(parameters, closedCallback);

[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
public Task OpenUpbeatViewModelAsync<TParameters>(TParameters parameters) =>
OpenViewModelAsync(parameters);

public void OpenViewModel<TParameters>(TParameters parameters) =>
OpenViewModel(parameters, null);

Expand All @@ -76,10 +57,6 @@ public Task OpenViewModelAsync<TParameters>(TParameters parameters)
return taskCompletionSource.Task;
}

[Obsolete("This will be removed in UpbeatUI 3.0. Use another injected service instead.")]
public void SetClipboard(string text) =>
Clipboard.SetText(text);

public void SetCloseCallback(Func<bool> okToCloseCallback) =>
_asyncOkToCloseCallback = () => Task.FromResult(okToCloseCallback());

Expand All @@ -94,15 +71,6 @@ internal object Activate(Func<IUpbeatService, object> viewModelCreator, Func<obj
var viewModel = viewModelCreator(this);
_isActiveViewModel = () => isActiveViewModel(viewModel);
_closer = () => closer(viewModel);
if (viewModel is IUpdatableViewModel updatableViewModel)
_updateCallback = updatableViewModel.UpdateViewModelProperties;
if (viewModel is IUpbeatViewModel upbeatViewModel)
_asyncOkToCloseCallback = () =>
{
bool okToClose = false;
upbeatViewModel.SignalToClose(() => okToClose = true);
return Task.FromResult(okToClose);
};
return viewModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace UpbeatUI.ViewModel
{
public partial class UpbeatStack : BaseViewModel, IDisposable, IUpdatableViewModel
public partial class UpbeatStack : BaseViewModel, IDisposable
{
private class UpbeatServiceDeferrer : ActionDeferrer
{
Expand Down
72 changes: 1 addition & 71 deletions source/UpbeatUI/ViewModel/UpbeatStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace UpbeatUI.ViewModel
/// <summary>
/// Represents a stack of ViewModels and provides methods and commands for controlling them.
/// </summary>
public partial class UpbeatStack : BaseViewModel, IOpensViewModels, IOpensUpbeatViewModels, IDisposable
public partial class UpbeatStack : BaseViewModel, IOpensViewModels, IDisposable
{
private delegate object ViewModelCreator(IUpbeatService upbeatService, object parameters);

Expand All @@ -40,23 +40,13 @@ public UpbeatStack(bool updateOnRender = true)
CompositionTarget.Rendering += UpdateViewModelProperties;
}

/// <summary>
/// Gets the <see cref="UpbeatStack"/>'s currently defined mappings between ViewModels and <see cref="UIElement"/> (Views).
/// </summary>
[Obsolete("Replaced by internal mechanisms. This property returns null and will be removed in UpbeatUI 3.0.")]
public IReadOnlyDictionary<Type, Type> UpbeatViewModelControlMappings => ViewModelControlMappings;
/// <summary>
/// Gets the <see cref="UpbeatStack"/>'s currently defined mappings between ViewModels and <see cref="UIElement"/> (Views).
/// </summary>
public IReadOnlyDictionary<Type, Type> ViewModelControlMappings => null;
/// <summary>
/// Gets the <see cref="UpbeatStack"/>'s current ViewModels.
/// </summary>
[Obsolete("Replaced by internal mechanisms. This property returns null and will be removed in UpbeatUI 3.0.")]
public INotifyCollectionChanged UpbeatViewModels => ViewModels;
/// <summary>
/// Gets the <see cref="UpbeatStack"/>'s current ViewModels.
/// </summary>
public INotifyCollectionChanged ViewModels { get; }
/// <summary>
/// Gets the count of the <see cref="UpbeatStack"/>'s current ViewModels.
Expand All @@ -65,24 +55,10 @@ public UpbeatStack(bool updateOnRender = true)
/// <summary>
/// Gets a command to remove the top (active) ViewModel.
/// </summary>
[Obsolete("Renamed to RemoveTopViewModelCommand. This property will be removed in UpbeatUI 3.0.")]
public ICommand RemoveTopUpbeatViewModelCommand => RemoveTopViewModelCommand;
/// <summary>
/// Gets a command to remove the top (active) ViewModel.
/// </summary>
public ICommand RemoveTopViewModelCommand { get; }
/// <summary>
/// Gets or sets an <see cref="Action"/> callback that the <see cref="UpbeatStack"/> will execute when it is empty of ViewModels.
/// </summary>
[Obsolete("Renamed to ViewModelsEmptyCallback. This property will be removed in UpbeatUI 3.0.")]
public Action UpbeatViewModelsEmptyCallback
{
get => ViewModelsEmptyCallback;
set => ViewModelsEmptyCallback = value;
}
/// <summary>
/// Gets or sets an <see cref="Action"/> callback that the <see cref="UpbeatStack"/> will execute when it is empty of ViewModels.
/// </summary>
public Action ViewModelsEmptyCallback { get; set; }

public void Dispose()
Expand All @@ -93,19 +69,6 @@ public void Dispose()
upbeatViewModel.Dispose();
}

/// <summary>
/// Defines a mapping between the <typeparamref name="TParameters"/> type, the <typeparamref name="TViewModel"/> Type and the <typeparamref name="TView"/> Type.
/// </summary>
/// <typeparam name="TParameters">The type of the parameters used to create <typeparamref name="TViewModel"/>.</typeparam>
/// <typeparam name="TViewModel">The type of the ViewModel created from a <typeparamref name="TParameters"/>.</typeparam>
/// <typeparam name="TView">The Type of the <see cref="UIElement"/>.</typeparam>
/// <param name="viewModelCreator">The delegate that will executed to create the ViewModel from an <see cref="IUpbeatService"/> and <typeparamref name="TParameters"/>.</param>
[Obsolete("Renamed to MapViewModel. This method will be removed in UpbeatUI 3.0.")]
public void MapUpbeatViewModel<TParameters, TViewModel, TView>(
Func<IUpbeatService, TParameters, TViewModel> viewModelCreator)
where TView : UIElement =>
MapViewModel<TParameters, TViewModel, TView>(viewModelCreator);

/// <summary>
/// Defines a mapping between the <typeparamref name="TParameters"/> type, the <typeparamref name="TViewModel"/> Type and the <typeparamref name="TView"/> Type.
/// </summary>
Expand Down Expand Up @@ -135,18 +98,6 @@ public void MapViewModel<TParameters, TViewModel, TView>(IServiceProvider servic
where TView : UIElement =>
MapViewModel(serviceProvider, typeof(TParameters), typeof(TViewModel), typeof(TView));

[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
public void OpenUpbeatViewModel<TParameters>(TParameters parameters) =>
OpenViewModel(parameters);

[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
public void OpenUpbeatViewModel<TParameters>(TParameters parameters, Action closedCallback) =>
OpenViewModel(parameters, closedCallback);

[Obsolete("Renamed to OpenViewModelAsync. This method will be removed in UpbeatUI 3.0.")]
public Task OpenUpbeatViewModelAsync<TParameters>(TParameters parameters) =>
OpenViewModelAsync(parameters);

public void OpenViewModel<TParameters>(TParameters parameters) =>
OpenViewModel(parameters, null);

Expand Down Expand Up @@ -174,27 +125,6 @@ public Task OpenViewModelAsync<TParameters>(TParameters parameters)
return taskCompletionSource.Task;
}

/// <summary>
/// Closes and disposes all ViewModels from the <see cref="UpbeatStack"/>.
/// </summary>
[Obsolete("Use TryCloseAllViewModelsAsync instead, which gives ViewModels a chance to cancel closing (e.g., to save unsaved work). This method will be removed in UpbeatUI 3.0.")]
public void RemoveAllUpbeatViewModels()
{
foreach (var viewModel in _openViewModels.Reverse())
RemoveViewModel(viewModel);
}

/// <summary>
/// Executes the <see cref="UpdateViewModelProperties"/> method on each ViewModel that implements the <see cref="IUpdatableViewModel"/> interface. This is a convenience method that can easily be subscribed to the <see cref="CompositionTarget.Rendering"/> event, which fires for each frame render.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">An object that contains no event data.</param>
[Obsolete("The UpbeatStack will automatically execute UpdateViewModelProperties on each frame render unless it is constructed with 'updateOnRender' as false. This handler is now a noop and will be removed in UpbeatUI 3.0.")]
public void RenderingHandler(object sender, EventArgs e)
{
return;
}

/// <summary>
/// Sets the <see cref="UpbeatStack"/> to automatically map Parameters <see cref="Type"/>s to ViewModel <see cref="Type"/>s and View <see cref="Type"/>s using the default conventions.
/// <para>Parameters class names must follow the pattern of: "{BaseNamespace}.ViewModel.{Name}ViewModel+Parameters" (The Parameters class must be a public nested class of the ViewModel class).</para>
Expand Down
21 changes: 0 additions & 21 deletions source/UpbeatUI/ViewModel/UpbeatViewModel.cs

This file was deleted.

0 comments on commit 6e9130c

Please sign in to comment.