本文整理汇总了C#中IMediator.InitializeNotifier方法的典型用法代码示例。如果您正苦于以下问题:C# IMediator.InitializeNotifier方法的具体用法?C# IMediator.InitializeNotifier怎么用?C# IMediator.InitializeNotifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediator
的用法示例。
在下文中一共展示了IMediator.InitializeNotifier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterMediator
/// <summary>
/// Register an <c>IMediator</c> instance with the <c>View</c>
/// </summary>
/// <param name="mediator">A reference to the <c>IMediator</c> instance</param>
/// <remarks>
/// <para>Registers the <c>IMediator</c> so that it can be retrieved by name, and further interrogates the <c>IMediator</c> for its <c>INotification</c> interests</para>
/// <para>If the <c>IMediator</c> returns any <c>INotification</c> names to be notified about, an <c>Observer</c> is created encapsulating the <c>IMediator</c> instance's <c>handleNotification</c> method and registering it as an <c>Observer</c> for all <c>INotifications</c> the <c>IMediator</c> is interested in</para>
/// </remarks>
/// <remarks>This method is thread safe and needs to be thread safe in all implementations.</remarks>
public virtual void RegisterMediator(IMediator mediator)
{
lock (m_mediatorMap)
{
// do not allow re-registration (you must to removeMediator fist)
if (m_mediatorMap.ContainsKey(mediator.MediatorName)) return;
mediator.InitializeNotifier(m_multitonKey);
// Register the Mediator for retrieval by name
m_mediatorMap[mediator.MediatorName] = mediator;
// Get Notification interests, if any.
var interests = mediator.ListNotificationInterests;
// Register Mediator as an observer for each of its notification interests
// Create Observer
IObserver observer = new Observer("handleNotification", mediator);
// Register Mediator as Observer for its list of Notification interests
foreach (var t in interests)
{
RegisterObserver(t, observer);
}
}
// alert the mediator that it has been registered
mediator.OnRegister();
}