Beispiel #1
0
        public void Add(TKey key, TValue value)
        {
            //This is multicast delegate create contiuation
            var val = DictionaryUtils.CreatePromise(stateManager, ((Delegate)(object)value));

            internalDictCase5.Add(key, new CollectionStateObjectReference((IStateObject)val));
            AddReferenceIntoStateObjectSurrogate(val);
        }
Beispiel #2
0
        /// <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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Removing the reference from the surrogate.
        /// </summary>
        /// <param name="internalValue"></param>
        private void RemoveReferenceFromStateObjectSurrogate(CollectionStateObjectReference internalValue)
        {
            var obj = internalValue.Target as IPromise;

            if (obj != null)
            {
                var surrogate = DictionaryUtils.GetObjectContainingMethod(obj) as IStateObjectSurrogate;
                if (surrogate != null)
                {
                    surrogateManager.RemoveSurrogateReference(surrogate, (IStateObject)obj);
                }
            }
        }
Beispiel #4
0
        public bool TryGetValue(TKey key, out TValue value)
        {
            CollectionStateObjectReference internalValue;
            var ret = internalDictCase5.TryGetValue(key, out internalValue);

            if (ret)
            {
                var cont = internalValue.Target as IPromise;
                if (cont != null)
                {
                    value = (TValue)DictionaryUtils.RetrieveDelegateFromPromise(typeof(TValue), cont);
                }
                else
                {
                    value = default(TValue);
                }
                return(true);
            }
            value = default(TValue);
            return(false);
        }
Beispiel #5
0
 public TValue this [TKey key] {
     get {
         var    entry5    = internalDictCase5[key];
         TValue retEntry5 = (TValue)DictionaryUtils.RetrieveDelegateFromPromise(typeof(TValue), (IPromise)entry5.Target);
         return(retEntry5);
     }
     set {
         //Erase old reference
         CollectionStateObjectReference internalValue;
         if (internalDictCase5.TryGetValue(key, out internalValue) /*&& internalValue !=null*/)
         {
             if (!internalValue.IsNull)
             {
                 stateManager.RemoveObject(internalValue.TargetUniqueID, mustDetach: true, deep: true);
                 RemoveReferenceFromStateObjectSurrogate(internalValue);
             }
         }
         //This is multicast delegate create contiuation
         var val = DictionaryUtils.CreatePromise(stateManager, ((Delegate)(object)value));
         internalDictCase5 [key] = new CollectionStateObjectReference((IStateObject)val);
         AddReferenceIntoStateObjectSurrogate(val);
     }
 }