public void Add(TKey key, TValue value)
        {
            var collectionStateObjectReference = value == null ? CollectionStateObjectReference.NullInstance: new CollectionStateObjectReference((IStateObject)value);

            internalDictCase2.Add(key, collectionStateObjectReference);
            var stateObject = (IStateObject)value;

            if (stateObject != null)
            {
                if (!_stateManager.IsStateObjectAllAttached(stateObject))
                {
                    _stateManager.RegisterPossibleOrphan(_parent, stateObject);
                }
                _referencesManager.Subscribe(_parent, stateObject);
            }
        }
        public void Add(TKey key, TValue value)
        {
            var surrogate = surrogateManager.GetStateObjectSurrogate(value, true);

            //TODO: There is a risk of having the UniqueId become invalid.
            surrogateManager.AddSurrogateReference(surrogate, _parent);

            internalDictCase6.Add(key, new CollectionStateObjectReference((IStateObject)surrogate));
            //The surrogate might not have a parent and the dictionary might need to adopt it.
            var stateObject = (IStateObject)surrogate;

            if (stateObject != null)
            {
                if (!_stateManager.IsStateObjectAllAttached(stateObject))
                {
                    _stateManager.RegisterPossibleOrphan(_parent, stateObject);
                }
                referencesManager.Subscribe(valueObject: _parent, referenceObject: stateObject);
            }
        }
Beispiel #3
0
 protected void SubscribeToReferenceManager(IReferenceManager _referenceManager, Page page, object item)
 {
     //Subscribe the item into the page's reference table
     _referenceManager.Subscribe(page, item);
 }