|
//----------------------------------------------------------------------------------------
// patterns & practices - Smart Client Software Factory - Guidance Package
//
// This file was generated by this guidance package as part of the solution template
//
// This class contains code that otherwise would be repeated in every presenter when using the M-V-P pattern.
// It includes a reference to a generic view and a reference to the WorkItem it belongs.
// It also provides virtual methods to work with the controlled view
//
// For more information see:
// ms-help://MS.VSCC.v80/MS.VSIPCC.v80/ms.scsf.2006jun/SCSF/html/03-210-Creating%20a%20Smart%20Client%20Solution.htm
//
// Latest version of this Guidance Package: http://go.microsoft.com/fwlink/?LinkId=62182
//----------------------------------------------------------------------------------------
using Microsoft.Practices.CompositeUI;
using System;
using Microsoft.Practices.CompositeUI.SmartParts;
namespace Matias.Infrastructure.Interface
{
public abstract class Presenter<TView> : IDisposable
{
private TView _view;
private WorkItem _workItem;
public TView View
{
get { return _view; }
set { _view = value; OnViewSet(); }
}
[ServiceDependency]
public WorkItem WorkItem
{
get { return _workItem; }
set { _workItem = value; }
}
protected virtual void CloseView()
{
Services.IWorkspaceLocatorService locator = WorkItem.Services.Get<Services.IWorkspaceLocatorService>();
IWorkspace wks = locator.FindContainingWorkspace(WorkItem, View);
if (wks != null)
wks.Close(View);
}
public virtual void OnViewReady() { }
protected virtual void OnViewSet() { }
~Presenter()
{
Dispose(false);
}
/// <summary>
/// See <see cref="System.IDisposable.Dispose"/> for more information.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Called when the object is being disposed or finalized.
/// </summary>
/// <param name="disposing">True when the object is being disposed (and therefore can
/// access managed members); false when the object is being finalized without first
/// having been disposed (and therefore can only touch unmanaged members).</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
if (_workItem != null)
_workItem.Items.Remove(this);
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.