Exemplo n.º 1
0
        /// <summary>
        ///     Hook into navigation event
        /// </summary>
        /// <param name="e">View navigation args</param>
        public void HandleEvent(ViewNavigationArgs e)
        {
            if (e.Deactivate)
            {
                ViewModelRouter.DeactivateView(e.ViewType);
                EventAggregator.Publish(new ViewNavigatedArgs(e.ViewType)
                {
                    Deactivate = true
                });
                return;
            }

            // does a view location exist?
            var viewLocation =
                (from location in _fluentRoutes
                 where location.ViewName.Equals(e.ViewType, StringComparison.InvariantCultureIgnoreCase)
                 select location).FirstOrDefault() ??
                (from location in ViewLocations
                 where location.ViewName.Equals(e.ViewType, StringComparison.InvariantCultureIgnoreCase)
                 select location).FirstOrDefault();

            // if so, try to load the dll, then activate the view
            if (viewLocation != null)
            {
                DeploymentService.RequestModule(viewLocation.View,
                                                exception =>
                {
                    if (exception != null)
                    {
                        throw exception;
                    }
                    _ActivateView(e.ViewType, e.ViewParameters);
                });
            }
            else
            {
                // just activate the view directly
                _ActivateView(e.ViewType, e.ViewParameters);
            }
        }