当前位置: 首页>>代码示例>>C#>>正文


C# IMediator.InitializeNotifier方法代码示例

本文整理汇总了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();
        }
开发者ID:xojunzheng,项目名称:puremvc-csharp-multicore-framework,代码行数:36,代码来源:View.cs


注:本文中的IMediator.InitializeNotifier方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。