Example #1
0
        public bool TryOpenPropItemSet(BagNode propBagNode)
        {
            bool result;

            PropNodeCollectionInternalInterface pnc_int = propBagNode.PropNodeCollection;

            if (!pnc_int.IsFixed)
            {
                System.Diagnostics.Debug.WriteLine("Warning: PropStoreAccessServiceProvider is being asked to open a PropItemSet that is already open.");
                result = true;
            }
            else
            {
                // Create a new collection. (New Collections are open by default.)
                PropNodeCollectionInternalInterface newOpenCollection = new PropNodeCollection(pnc_int);

                // Remove the old set from the StoreByType
                RemoveFixedPropCollection(propBagNode.ObjectId, pnc_int);

                // Replace the exixting collection with the new one.
                propBagNode.PropNodeCollection = newOpenCollection;

                // return a reference to the new one cast as an object.
                result = true;
            }

            return(result);
        }
Example #2
0
        private PropNodeCollectionIntInterface ClonePropNodes(PropNodeCollectionIntInterface sourcePNC, BagNode targetParent)
        {
            PropNodeCollectionIntInterface result;

            List <PropNode> newPropNodeColl = new List <PropNode>();

            foreach (PropNode propNode in sourcePNC.GetPropNodes())
            {
                PropNode newPropNode = propNode.CloneForNewParent(targetParent, useExistingValues: true);
                newPropNodeColl.Add(newPropNode);
            }

            if (sourcePNC.IsFixed)
            {
                System.Diagnostics.Debug.Assert(!sourcePNC.PropItemSetKey.IsEmpty, "We found a fixed PropSetCollection that has an empty PropItemSetKey.");
                // Create a Fixed PropNodeCollection.
                result = new PropNodeCollectionFixed(newPropNodeColl, sourcePNC.PropItemSetKey, sourcePNC.MaxPropsPerObject);
            }
            else
            {
                // Create an open PropNodeCollection.
                result = new PropNodeCollection(newPropNodeColl, sourcePNC.PropItemSetKey, sourcePNC.MaxPropsPerObject);
            }

            return(result);
        }