예제 #1
0
        /// <summary>
        /// Creates a reference table to an Object.
        /// </summary>
        /// <param name="valueObject"></param>
        /// <returns></returns>
        private ReferencesTable CreateObjectReferencesTable(IStateObject valueObject)
        {
            var new_relativeUid = UniqueIDGenerator.GetReferenceTableRelativeUniqueID(valueObject.UniqueID);

            LazyBehaviours.AddDependent(valueObject, UniqueIDGenerator.REFTABLEPrefix);
            ReferencesTable referencesTable = new ReferencesTable();

            referencesTable.UniqueID = new_relativeUid;
            referencesTable.IsReferencedObjectAnIDisposableDependencyControl = valueObject is IDisposableDependencyControl;

            if (StateManager.AllBranchesAttached(valueObject))
            {
                //at this point we have a new pointer with an attached parent
                //which means that it was born on the temp stateManager
                //we cannot just do a switchunique ids because switching
                //is only on the stateManager level
                //we need to promote it from temp to StateManager
                //to make sure that it will be persisted
                _stateManager.AddNewAttachedObject(referencesTable);
            }
            else
            {
                //at this point we have a new pointer with an UNATTACHED parent
                //which means both the parent and the pointer are on the temp stateManager
                //we need to switchunique ids because
                //they are at the stateManager level
                //if the parent is promoted so will be the pointer
                _stateManager.AddNewTemporaryObject(referencesTable);
            }
            return(referencesTable);
        }
예제 #2
0
        /// <summary>
        /// Gets the References table associated to an IStateObject
        /// </summary>
        /// <param name="valueObject"></param>
        /// <returns></returns>
        private ReferencesTable GetObjectReferencesTable(string uniqueID)
        {
            ReferencesTable result   = null;
            var             uniqueId = UniqueIDGenerator.GetReferenceTableRelativeUniqueID(uniqueID);
            var             obj      = _stateManager.GetObject(uniqueId);

            if (obj != null)
            {
                result = obj as ReferencesTable;
            }
            return(result);
        }