Example #1
0
		/// <summary>
		/// Visits the active command route
		/// </summary>
		/// <returns>
		/// Visitor result
		/// </returns>
		/// <param name='visitor'>
		/// Visitor.
		/// </param>
		/// <param name='initialTarget'>
		/// Initial target (provide null to use the default initial target)
		/// </param>
		public object VisitCommandTargets (ICommandTargetVisitor visitor, object initialTarget)
		{
			CommandTargetRoute targetRoute = new CommandTargetRoute (initialTarget);
			object cmdTarget = GetFirstCommandTarget (targetRoute);

			visitor.Start ();

			try {
				while (cmdTarget != null)
				{
					if (visitor.Visit (cmdTarget))
						return cmdTarget;

					cmdTarget = GetNextCommandTarget (targetRoute, cmdTarget);
				}
			} catch (Exception ex) {
				LoggingService.LogError ("Error while visiting command targets", ex);
			} finally {
				visitor.End ();
			}
			return null;
		}