本文整理汇总了C#中IMediator.ListNotificationInterests方法的典型用法代码示例。如果您正苦于以下问题:C# IMediator.ListNotificationInterests方法的具体用法?C# IMediator.ListNotificationInterests怎么用?C# IMediator.ListNotificationInterests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMediator
的用法示例。
在下文中一共展示了IMediator.ListNotificationInterests方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterMediator
// Facade
public virtual void RegisterMediator(IMediator mediator)
{
if(m_mediatorMap.ContainsKey(mediator.MediatorName))
{
return;
}
m_mediatorMap[mediator.MediatorName] = mediator;
IList<Enum> interests = mediator.ListNotificationInterests();
if(interests.Count > 0)
{
IObserver observer = new Observer("handleNotification", mediator);
for(int i = 0; i < interests.Count; i++)
{
RegisterObserver(interests[i], observer);
}
}
mediator.OnRegister();
mediator.RegisterInterestsUI();
mediator.RegisterInterestsMsg();
}
示例2: RegisterMediator
//注册视图组件
public virtual void RegisterMediator(IMediator mediator)
{
lock(m_syncLocker)
{
if (m_mediatorMap.ContainsKey(mediator.MediatorName))
return;
m_mediatorMap[mediator.MediatorName] = mediator;
//获取观察者上所有的消息
IList<string> interests = mediator.ListNotificationInterests();
if (interests.Count > 0)
{
IObserver server = new Observer("handleNotification",mediator);
for (int i = 0; i < interests.Count; ++i )
{
//notification列表
RegisterObserver(interests[i], server);
}
}
}
mediator.OnRegister();
}
示例3: 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_syncRoot)
{
// do not allow re-registration (you must to removeMediator fist)
if (m_mediatorMap.ContainsKey(mediator.MediatorName)) return;
// Register the Mediator for retrieval by name
m_mediatorMap[mediator.MediatorName] = mediator;
// Get Notification interests, if any.
IList<string> interests = mediator.ListNotificationInterests();
// Register Mediator as an observer for each of its notification interests
if (interests.Count > 0)
{
// Create Observer
IObserver observer = new Observer("handleNotification", mediator);
// Register Mediator as Observer for its list of Notification interests
for (int i = 0; i < interests.Count; i++)
{
RegisterObserver(interests[i].ToString(), observer);
}
}
}
// alert the mediator that it has been registered
mediator.OnRegister();
}