PureMVC.Interfaces.IMediator Interface Reference

The interface definition for a PureMVC Mediator. More...

Inheritance diagram for PureMVC.Interfaces.IMediator:

PureMVC.Patterns.Mediator

List of all members.

Public Member Functions

IList< string > ListNotificationInterests ()
void HandleNotification (INotification notification)
 Handle an INotification.
void OnRegister ()
 Called by the View when the Mediator is registered.
void OnRemove ()
 Called by the View when the Mediator is removed.

Properties

string MediatorName [get]
object ViewComponent [get, set]
 The IMediator's view component.


Detailed Description

The interface definition for a PureMVC Mediator.

In PureMVC, IMediator implementors assume these responsibilities:

Additionally, IMediators typically:

When an IMediator is registered with the IView, the IView will call the IMediator's listNotificationInterests method. The IMediator will return an IList of INotification names which it wishes to be notified about

The IView will then create an Observer object encapsulating that IMediator's (handleNotification) method and register it as an Observer for each INotification name returned by listNotificationInterests

A concrete IMediator implementor usually looks something like this:

        using PureMVC.Patterns.~~;
                using PureMVC.Core.View.~~;   
        using com.me.myapp.model.~~;
        using com.me.myapp.view.~~;
        using com.me.myapp.controller.~~;

        using System.Windows.Forms; 
        using System.Data;

        public class MyMediator : Mediator, IMediator {

                        public MyMediator( viewComponent:object ) {
                                base( viewComponent );
                    combo.DataSourceChanged += new EventHandler(onChange);
                        }

                        public IList listNotificationInterests() {
                                        return new string[] {
                             MyFacade.SET_SELECTION, 
                             MyFacade.SET_DATAPROVIDER };
                        }

                        public void handleNotification( notification:INotification ) {
                                        switch ( notification.getName() ) {
                                                case MyFacade.SET_SELECTION:
                                combo.SelectedItem = notification.getBody();
                                                        break;
set the data source of the combo box
                                                case MyFacade.SET_DATASOURCE:
                                                        combo.DataSource = notification.getBody();
                                                        break;
                                        }
                        }

Invoked when the combo box dispatches a change event, we send a
notification with the
                        protected void onChange(object sender, EventArgs e) {
                                sendNotification( MyFacade.MYCOMBO_CHANGED, sender );
                        }

A private getter for accessing the view object by class
             private ComboBox combo {
                 get { return view as ComboBox; }
             }

        }

PureMVC.Interfaces.INotification


Member Function Documentation

void PureMVC.Interfaces.IMediator.HandleNotification ( INotification  notification  ) 

Handle an INotification.

Parameters:
notification The INotification to be handled

Implemented in PureMVC.Patterns.Mediator.

IList<string> PureMVC.Interfaces.IMediator.ListNotificationInterests (  ) 

List INotification interests

Returns:
An IList of the INotification names this IMediator has an interest in

Implemented in PureMVC.Patterns.Mediator.

void PureMVC.Interfaces.IMediator.OnRegister (  ) 

Called by the View when the Mediator is registered.

Implemented in PureMVC.Patterns.Mediator.

void PureMVC.Interfaces.IMediator.OnRemove (  ) 

Called by the View when the Mediator is removed.

Implemented in PureMVC.Patterns.Mediator.


Property Documentation

string PureMVC.Interfaces.IMediator.MediatorName [get]

Tthe IMediator instance name

Implemented in PureMVC.Patterns.Mediator.

object PureMVC.Interfaces.IMediator.ViewComponent [get, set]

The IMediator's view component.

Implemented in PureMVC.Patterns.Mediator.


The documentation for this interface was generated from the following file:

Generated on Thu Jan 1 16:26:46 2009 for PureMVC by  doxygen 1.5.8