Example #1
0
        /// <summary>
        /// Relink a workspace to the workspace manager after it has been
        /// deserialized.
        /// </summary>
        private void RelinkWorkspaceObject(Workspace kws, KwsBrowserFolderNode folder, bool notifyFlag, bool notInDbFlag)
        {
            Debug.Assert(kws != null);

            // Call Initialize() to restore the link to us.
            kws.Initialize(this);

            // Insert the workspace in the database.
            if (notInDbFlag) AddKwsToDb(kws);

            // Add the workspace to the workspace tree.
            KwsTree[kws.InternalID] = kws;

            // The workspace has a serialized KAS, but it is not the same
            // object as the one serialized in the WM. We need to correct
            // that situation.
            WmKas kas = GetOrCreateKas(kws.Kas.KasID);
            kws.Kas = kas;
            kas.KwsTree.Add(kws.InternalID, kws);

            // Make sure our workspace ID generator is in a sane state.
            NextKwsInternalId = Math.Max(NextKwsInternalId, kws.InternalID + 1);

            // Add the workspace to the browser.
            UiBroker.Browser.AddKws(kws, folder, false);

            // Set the node's Notify flag. Checking the return value is unnecessary.
            if (notifyFlag)
                UiBroker.MarkNodeNotifyFlag(kws);
        }