Beispiel #1
0
        private void CreateItem(ObjectClass dtType)
        {
            var isSimpleObject = dtType.IsSimpleObject;

            var newCtx = isSimpleObject ? DataContext : ctxFactory();
            var newObj = newCtx.Create(DataContext.GetInterfaceType(dtType.GetDataType()));

            OnObjectCreated(newObj);

            if (!isSimpleObject)
            {
                var newWorkspace = ViewModelFactory.CreateViewModel <ObjectEditorWorkspace.Factory>().Invoke(newCtx, null);
                newWorkspace.ShowForeignModel(DataObjectViewModel.Fetch(ViewModelFactory, newCtx, newWorkspace, newObj), RequestedEditorKind);
                ViewModelFactory.ShowModel(newWorkspace, RequestedWorkspaceKind, true);
            }
            else if (Listener != null)
            {
                Listener.Refresh();
            }
        }
Beispiel #2
0
        private void CreateItem(ObjectClass dtType)
        {
            if (UseSeparateContext)
            {
                var newScope = ViewModelFactory.CreateNewScope();
                var newCtx = newScope.ViewModelFactory.CreateNewContext();
                var newObj = newCtx.Create(newCtx.GetInterfaceType(dtType.GetDataType()));
                OnObjectCreated(newObj);
                ActivateForeignItems(newScope, newCtx, new[] { newObj });
            }
            else
            {
                var newObj = DataContext.Create(DataContext.GetInterfaceType(dtType.GetDataType()));
                OnObjectCreated(newObj);

                var mdl = DataObjectViewModel.Fetch(ViewModelFactory, DataContext, ViewModelFactory.GetWorkspace(DataContext), newObj);
                OnLocalModelCreated(mdl);

                ActivateItem(new[] { mdl });

                OnRefresh();
            }
        }