示例#1
0
        public void OpenApplication(ApplicationViewModel appMdl)
        {
            if (appMdl == null) throw new ArgumentNullException("appMdl");

            var newScope = ViewModelFactory.CreateNewScope();

            if (appMdl.WindowModelType != null)
            {
                var newWorkspace = newScope.ViewModelFactory.CreateViewModel<WindowViewModel.Factory>(appMdl.WindowModelType).Invoke(
                    newScope.ViewModelFactory.CreateNewContext(ContextIsolationLevel.MergeQueryData), // no data changes in applications! Open a workspace
                    null
                );
                newWorkspace.Closed += (s, e) => newScope.Dispose();
                ViewModelFactory.ShowModel(newWorkspace, true);
            }
            else if (appMdl.RootScreen != null)
            {
                var newWorkspace = newScope.ViewModelFactory.CreateViewModel<NavigatorViewModel.Factory>().Invoke(
                    newScope.ViewModelFactory.CreateNewContext(ContextIsolationLevel.MergeQueryData), // no data changes on navigation screens! Open a workspace
                    null,
                    appMdl.RootScreen
                );
                newWorkspace.Closed += (s, e) => newScope.Dispose();
                ViewModelFactory.ShowModel(newWorkspace, true);
            }
            else
            {
                // TODO: protect by constraint. See Case#1649
                throw new NotSupportedException("Application has no defined startup Screen");
            }
        }
示例#2
0
        public void OpenApplication(ApplicationViewModel appMdl)
        {
            if (appMdl == null) throw new ArgumentNullException("appMdl");

            if (appMdl.WindowModelType != null)
            {
                // responsibility to externalCtx's disposal passes to newWorkspace
                var newWorkspace = ViewModelFactory.CreateViewModel<WindowViewModel.Factory>(appMdl.WindowModelType).Invoke(
                    ctxFactory(ClientIsolationLevel.MergeServerData) // no data changes in applications! Open a workspace
                    , null
                );
                ViewModelFactory.ShowModel(newWorkspace, true);
            }
            else if (appMdl.RootScreen != null)
            {
                var newWorkspace = ViewModelFactory.CreateViewModel<NavigatorViewModel.Factory>().Invoke(
                    ctxFactory(ClientIsolationLevel.MergeServerData), // no data changes on navigation screens! Open a workspace
                    null,
                    appMdl.RootScreen
                );
                ViewModelFactory.ShowModel(newWorkspace, true);
            }
            else
            {
                // TODO: protect by constraint. See Case#1649
                throw new NotSupportedException("Application has no defined startup Screen");
            }
        }