示例#1
0
文件: View.cs 项目: stonerey/lizzard
        /// <inheritdoc />
        /// <summary>
        /// Retrieve an <c>IMediator</c> from the <c>View</c>.
        /// </summary>
        /// <param name="mediatorName">the name of the <c>IMediator</c> instance to retrieve.</param>
        /// <returns>the <c>IMediator</c> instance previously registered with the given <c>mediatorName</c>.</returns>
        public virtual IMediator RetrieveMediator(string mediatorName)
        {
            IMediator mediator;

            MediatorMap.TryGetValue(mediatorName, out mediator);
            return(mediator);
        }
		public void SetUp()
		{
			Context context = new Context();
			mediatorMap = new MediatorMap(context);

			context.injector.Map(typeof(MediatorWeakMapTracker)).ToValue(new MediatorWeakMapTracker());
		}
		public void SetUp()
		{
			Context context = new Context();
			injector = context.injector;
			mediatorMap = new MediatorMap(context);
			mediatorWatcher = new MediatorWatcher();
			injector.Map(typeof(MediatorWatcher)).ToValue(mediatorWatcher);
		}
示例#4
0
        /*============================================================================*/
        /* Private Functions                                                          */
        /*============================================================================*/

        private void BeforeInitializing()
        {
            _mediatorMap = _injector.GetInstance(typeof(IMediatorMap)) as MediatorMap;
            _viewManager = _injector.GetInstance(typeof(IViewManager)) as IViewManager;
            if (_viewManager != null)
            {
                _viewManager.AddViewHandler(_mediatorMap);
            }
        }
		/*============================================================================*/
		/* Private Functions                                                          */
		/*============================================================================*/

		private void BeforeInitializing()
		{
			_mediatorMap = _injector.GetInstance(typeof(IMediatorMap)) as MediatorMap;
			_viewManager = _injector.GetInstance(typeof(IViewManager)) as IViewManager;
			if (_viewManager != null)
			{
				_viewManager.AddViewHandler (_mediatorMap);
			}
		}
示例#6
0
文件: View.cs 项目: stonerey/lizzard
        /// <inheritdoc />
        /// <summary>
        /// Remove an <c>IMediator</c> from the <c>View</c>.
        /// </summary>
        /// <param name="mediatorName">name of the <c>IMediator</c> instance to be removed.</param>
        /// <returns>the <c>IMediator</c> that was removed from the <c>View</c></returns>
        public virtual IMediator RemoveMediator(string mediatorName)
        {
            if (!MediatorMap.ContainsKey(mediatorName))
            {
                return(null);
            }
            var mediator  = MediatorMap[mediatorName];
            var interests = mediator.ListNotificationInterests();

            foreach (var i in interests)
            {
                RemoveObserver(i, mediator);
            }
            mediator.OnRemove();
            return(mediator);
        }
示例#7
0
文件: View.cs 项目: stonerey/lizzard
        /// <inheritdoc />
        /// <summary>
        /// Register an <c>IMediator</c> instance with the <c>View</c>.
        /// </summary>
        /// <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>
        /// <param name="mediator">the name to associate with this <c>IMediator</c> instance</param>
        public virtual void RegisterMediator(IMediator mediator)
        {
            if (MediatorMap.ContainsKey(mediator.MediatorName))
            {
                return;
            }

            MediatorMap[mediator.MediatorName] = mediator;
            var interests = mediator.ListNotificationInterests();

            if (interests.Length > 0)
            {
                var observer = new Observer(mediator.HandleNotification, mediator);
                foreach (var i in interests)
                {
                    RegisterObserver(i, observer);
                }
            }

            // alert the mediator that it has been registered
            mediator.OnRegister();
        }
示例#8
0
文件: View.cs 项目: stonerey/lizzard
 /// <inheritdoc />
 /// <summary>
 /// Check if a Mediator is registered or not
 /// </summary>
 /// <param name="mediatorName"></param>
 /// <returns>whether a Mediator is registered with the given <c>mediatorName</c>.</returns>
 public virtual bool HasMediator(string mediatorName)
 {
     return(MediatorMap.ContainsKey(mediatorName));
 }
		public void TearDown()
		{
			mediatorMap = null;
			mediatorManager = null;
			mediatorTracker = null;
		}
		public void SetUp()
		{
			Context context = new Context();
			mediatorMap = new MediatorMap(context);
		}