コード例 #1
0
        /// <summary>
        /// Processes the specified navigation context.
        /// </summary>
        /// <param name="navigationContext">The navigation context.</param>
        public void Process( NavigationContext navigationContext )
        {
            Check.IsNotNull ( navigationContext, "Navigation Context cannot be null." );

            var commandName = navigationContext.TryGetNavigationParameter<string> ( _commandNameParameter );
            if ( _commandHandlers.ContainsKey ( commandName ) )
            {
                _commandHandlers[commandName] ( navigationContext );
            }
            else
            {
                if ( _defaultHandler != null )
                {
                    _defaultHandler ( navigationContext );
                }
                if ( _throwExceptionIfDefault )
                {
                    throw new ArgumentException ( "Invalid Command Name:" + commandName );
                }
            }
        }
コード例 #2
0
        private INavigationCommand FindCommand ( NavigationContext navigationContext )
        {
            var commandName = navigationContext.TryGetNavigationParameter<string> ( "CommandName" );
            INavigationCommand commandToExecute;

            if ( string.IsNullOrWhiteSpace ( commandName ) )
            {
                commandToExecute = DefaultCommand;
            }
            else
            {
                if ( !commandName.EndsWith ( "Command" ) )
                {
                    commandName += "Command";
                }
                commandToExecute = _commandsList.ContainsKey ( commandName ) ? _commandsList[commandName] : DefaultCommand;
            }
            return commandToExecute;
        }