/// <summary> /// Adding a Reference to the event promise info. If we don't add the reference, the surrogate will no be persisted /// </summary> /// <param name="val"></param> private void AddReferenceIntoStateObjectSurrogate(IPromise val) { var stateObjectSurrogate = DictionaryUtils.GetObjectContainingMethod(val) as IStateObjectSurrogate; if (stateObjectSurrogate != null) { surrogateManager.AddSurrogateReference(stateObjectSurrogate, (IStateObject)val); } }
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); } }