Ejemplo n.º 1
0
        private static void RegisterInternal(CallbackDictionary callbacks, string id, IOperationCallback callback)
        {
            //Only for debug callback
            if (AlwaysSerializeCallback && callback.IsSerializable)
            {
                ISerializer serializer;
                if (ServiceProvider.IocContainer.TryGet(out serializer))
                {
                    var stream = serializer.Serialize(callback);
                    stream.Position = 0;
                    callback        = (IOperationCallback)serializer.Deserialize(stream);
                }
            }

            lock (callbacks)
            {
                List <object> list;
                if (!callbacks.TryGetValue(id, out list))
                {
                    list          = new List <object>();
                    callbacks[id] = list;
                }
                list.Add(callback);
            }
        }
Ejemplo n.º 2
0
        private static void InitializeCallbacks <T>(CallbackDictionary dictionary, OperationType type, ref List <IOperationCallback> list, T target, Action <T> clearDictAction)
        {
            if (dictionary == null)
            {
                return;
            }
            List <object> value;

            lock (dictionary)
            {
                if (dictionary.TryGetValue(type.Id, out value))
                {
                    dictionary.Remove(type.Id);
                }
                if (dictionary.Count == 0)
                {
                    clearDictAction(target);
                }
            }
            if (value == null)
            {
                return;
            }
            if (list == null)
            {
                list = new List <IOperationCallback>();
            }
            lock (value)
                list.AddRange(value.Cast <IOperationCallback>());
        }
Ejemplo n.º 3
0
        private void RegisterInternal(CallbackDictionary callbacks, string id, IOperationCallback callback)
        {
            //Only for debug
            if (AlwaysSerializeCallback && callback.IsSerializable)
            {
                var stream = _serializer.Serialize(callback);
                stream.Position = 0;
                callback        = (IOperationCallback)_serializer.Deserialize(stream);
            }

            List <object> list;

            lock (callbacks)
            {
                if (!callbacks.TryGetValue(id, out list))
                {
                    list          = new List <object>();
                    callbacks[id] = list;
                }
            }
            lock (list)
                list.Add(callback);
        }