예제 #1
0
        public INavigatorForm Open(object parameter)
        {
            Ensure.NotNull(parameter, "parameter");

            Type pageType;
            Type parameterType = parameter.GetType();

            ITemplate template = rootFrame.Content as ITemplate;

            if (template == null)
            {
                if (parameterType == typeof(MigrateParameter) && rules.TryGetPageType(parameterType, out pageType))
                {
                    return(new PageNavigatorForm(rootFrame, pageType, parameter));
                }

                Type templateType = typeof(Template);
                if (new MobileStateTrigger().IsActive)
                {
                    templateType = typeof(TemplateMobile);
                }

                return(new PageNavigatorForm(rootFrame, templateType, parameter));
            }

            if (rules.TryGetPageType(parameterType, out pageType))
            {
                Summary          summary          = template.ContentFrame.Content as Summary;
                SummaryParameter summaryParameter = parameter as SummaryParameter;
                if (summary != null && summaryParameter != null)
                {
                    summary.DecorateParameter(summaryParameter);
                }

                return(new PageNavigatorForm(template.ContentFrame, pageType, parameter));
            }

            if (rules.TryGetWizardType(parameterType, out pageType))
            {
                return(new WizardNavigatorForm(pageType, parameter, rootFrame, currentParameter));
            }

            throw Ensure.Exception.InvalidOperation("Missing navigation page for parameter of type '{0}'.", parameterType.FullName);
        }