Ejemplo n.º 1
0
 protected Type GetEnhancedTypeIntern(Type entityType, IEnhancementHint enhancementHint)
 {
     lock (writeLock)
     {
         WeakReference existingBaseTypeR = DictionaryExtension.ValueOrDefault(extendedTypeToType, entityType);
         if (existingBaseTypeR != null)
         {
             Type existingBaseType = (Type)existingBaseTypeR.Target;
             if (existingBaseType != null)
             {
                 // there is already an enhancement of the given baseType. Now we check if the existing enhancement is made with the same enhancementHint
                 ValueType valueType2 = DictionaryExtension.ValueOrDefault(typeToExtendedType, existingBaseType);
                 if (valueType2 != null && valueType2.ContainsKey(enhancementHint))
                 {
                     // do nothing: the given entity is already the result of the enhancement of the existingBaseType with the given enhancementHint
                     // it is not possible to enhance the same two times
                     return(entityType);
                 }
             }
         }
         ValueType valueType = DictionaryExtension.ValueOrDefault(typeToExtendedType, entityType);
         if (valueType == null)
         {
             return(null);
         }
         WeakReference extendedTypeR = valueType.Get(enhancementHint);
         if (extendedTypeR == null)
         {
             return(null);
         }
         return((Type)extendedTypeR.Target);
     }
 }
Ejemplo n.º 2
0
        public void UnregisterFirstLevelCache(IWritableCache firstLevelCache, CacheFactoryDirective cacheFactoryDirective, bool foreignThreadAware, String name)
        {
            // cacheFactoryDirective and foreignThreadAware will be intentionally ignored at unregister

            unboundWriteLock.Lock();
            try
            {
                CheckCachesForCleanup();
                int      cacheId  = firstLevelCache.CacheId;
                FlcEntry flcEntry = DictionaryExtension.ValueOrDefault(allFLCs, cacheId);
                if (flcEntry == null)
                {
                    throw new Exception("CacheId is not mapped to a valid cache instance");
                }
                IWritableCache existingChildCache = flcEntry.GetFirstLevelCache();
                if (existingChildCache == null)
                {
                    throw new Exception("Fatal error occured. Reference lost to cache");
                }
                if (existingChildCache != firstLevelCache)
                {
                    throw new Exception("Fatal error occured. CacheId invalid - it is not mapped to the specified cache instance");
                }
                allFLCs.Remove(cacheId);
                foreignThreadAware    = flcEntry.IsForeignThreadAware();
                cacheFactoryDirective = flcEntry.GetCacheFactoryDirective();

                LogFLC(firstLevelCache, cacheFactoryDirective, foreignThreadAware, name, flcEntry, false);
                firstLevelCache.CacheId = 0;
            }
            finally
            {
                unboundWriteLock.Unlock();
            }
        }
Ejemplo n.º 3
0
        public void Queue <T>(QueueGroupKey <T> queueGroupKey, IEnumerable <T> items)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    IList queue2 = queueGroup.Queue;
                    foreach (T item in items)
                    {
                        queue2.Add(item);
                    }
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey, new List <T>());
                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);

                IList queue = queueGroup.Queue;
                foreach (T item in items)
                {
                    queue.Add(item);
                }
                QueueIntern <T>(queueGroup);
            }
        }
Ejemplo n.º 4
0
 public K this[K key]
 {
     get
     {
         int hashKey = key.GetHashCode();
         List <WeakReference> list = DictionaryExtension.ValueOrDefault(dic, hashKey);
         if (list == null)
         {
             return(default(K));
         }
         for (int a = list.Count; a-- > 0;)
         {
             WeakReference p      = list[a];
             Object        target = p.Target;
             if (target == null)
             {
                 continue;
             }
             if (AreKeysEqual((K)target, key))
             {
                 return((K)target);
             }
         }
         return(default(K));
     }
     set
     {
         Add(key);
     }
 }
Ejemplo n.º 5
0
        public bool Add(K key)
        {
            int hashKey = key.GetHashCode();
            List <WeakReference> list = DictionaryExtension.ValueOrDefault(dic, hashKey);

            if (list == null)
            {
                list = new List <WeakReference>(2);
                dic.Add(hashKey, list);
            }
            for (int a = list.Count; a-- > 0;)
            {
                WeakReference p      = list[a];
                Object        target = p.Target;
                if (target == null)
                {
                    RemoveItemFromList(hashKey, list, a);
                    continue;
                }
                if (AreKeysEqual((K)target, key))
                {
                    return(false);
                }
            }
            WeakReference newP = new WeakReference(key);

            list.Add(newP);
            count++;
            return(true);
        }
Ejemplo n.º 6
0
        public int GetIdOfObject(Object obj)
        {
            bool isImmutableType = ImmutableTypeSet.IsImmutableType(obj.GetType());
            IDictionary <Object, int> objectToIdMap = isImmutableType ? immutableToIdMap : mutableToIdMap;

            return(DictionaryExtension.ValueOrDefault(objectToIdMap, obj));
        }
Ejemplo n.º 7
0
        public void Queue(QueueGroupKey queueGroupKey)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey);

                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);
                bool queueGroupAdded = false;

                // Insert the QueueGroup at the right position of pending QueueGroups
                // At index 0 is the latest of all, at max-index the next triggering QueueGroup
                for (int a = 0, size = pendingQueueGroups.Count; a < size; a++)
                {
                    QueueGroup pendingQueueGroup = pendingQueueGroups[a];
                    if (queueGroup.ExecutionTime >= pendingQueueGroup.ExecutionTime)
                    {
                        // If new QueueGroup executes AFTER or EQUAL TO the current investigated QueueGroup,
                        // insert the new QueueGroup BEFORE in the list
                        pendingQueueGroups.Insert(a, queueGroup);
                        queueGroupAdded = true;
                        break;
                    }
                }
                if (!queueGroupAdded)
                {
                    pendingQueueGroups.Add(queueGroup);
                }
            }
        }
Ejemplo n.º 8
0
        public IBeanConfiguration GetBeanConfiguration(String beanName)
        {
            if (nameToBeanConfMap == null || beanName == null)
            {
                return(null);
            }
            IBeanConfiguration beanConf = nameToBeanConfMap.Get(beanName);

            if (beanConf == null)
            {
                if (aliasToBeanNameMap != null)
                {
                    String aliasName = DictionaryExtension.ValueOrDefault(aliasToBeanNameMap, beanName);
                    if (aliasName != null)
                    {
                        beanConf = nameToBeanConfMap.Get(aliasName);
                    }
                }
            }
            if (beanConf == null && parent != null)
            {
                beanConf = parent.GetBeanConfiguration(beanName);
            }
            return(beanConf);
        }
Ejemplo n.º 9
0
        protected IObjRef ExtractAndMergeObjRef(IDataChangeEntry dataChangeEntry, IDictionary <IObjRef, IObjRef> touchedObjRefSet)
        {
            IEntityMetaData metaData = EntityMetaDataProvider.GetMetaData(dataChangeEntry.EntityType);
            IObjRef         objRef   = GetObjRef(dataChangeEntry, metaData);

            IObjRef existingObjRef = DictionaryExtension.ValueOrDefault(touchedObjRefSet, objRef);

            if (existingObjRef == null)
            {
                touchedObjRefSet.Add(objRef, objRef);
                return(objRef);
            }
            Object newVersion      = objRef.Version;
            Object existingVersion = existingObjRef.Version;

            if (newVersion == null)
            {
                return(existingObjRef);
            }
            if (existingVersion == null || ((IComparable)newVersion).CompareTo(existingVersion) >= 0)
            {
                existingObjRef.Version = newVersion;
            }
            return(existingObjRef);
        }
Ejemplo n.º 10
0
        public virtual void AfterPropertiesSet()
        {
            ParamChecker.AssertNotNull(SharedData, "SharedData");
            ParamChecker.AssertNotNull(SharedDataHandOnExtendable, "SharedDataHandOnExtendable");
            //ParamChecker.AssertNotNull(Data, "Data");
            if (Data == null)
            {
                Token = null;
                return;
            }
            IDictionary <String, IModelContainer> output = new Dictionary <String, IModelContainer>();

            foreach (String name in Data.Keys)
            {
                String beanName = DictionaryExtension.ValueOrDefault <String, String>(Data, name);
                if (beanName == null)
                {
                    //Output with value == null should be published with the same name as in the previous context
                    beanName = name;
                }
                output[name] = BeanContext.GetService <IModelContainer>(beanName);
            }
            output[DataConsumerModule.SourceUriBeanName] = BeanContext.GetService <IModelContainer>(DataConsumerModule.SourceUriBeanName);
            Token = SharedData.Put(output);
            //TODO: How to get the source URI saved for GoBack-Action?
        }
Ejemplo n.º 11
0
        public MethodInfo[] getAddRemoveMethodsForEvent(Type targetType, String eventName)
        {
            ParamChecker.AssertParamNotNull(targetType, "targetType");
            ParamChecker.AssertParamNotNull(eventName, "eventName");

            MethodInfo[] addRemoveMethods;
            EventKeyItem keyItem = new EventKeyItem(targetType, eventName);

            lock (typeToAddRemoveMethodsMapOld)
            {
                addRemoveMethods = DictionaryExtension.ValueOrDefault(typeToAddRemoveMethodsMapOld, keyItem);
                if (addRemoveMethods != null)
                {
                    return(addRemoveMethods);
                }
            }
            MethodInfo addMethod    = targetType.GetMethod("add_" + eventName);
            MethodInfo removeMethod = targetType.GetMethod("remove_" + eventName);

            if (addMethod == null || removeMethod == null)
            {
                throw new ExtendableException("No autogenerated event methods for event field '" + eventName + "' found on type " + targetType.Name
                                              + ". Looked for a member like 'public event " + typeof(PropertyChangedEventHandler).Name + " " + eventName + ";");
            }
            addRemoveMethods = new MethodInfo[] { addMethod, removeMethod };

            lock (typeToAddRemoveMethodsMapOld)
            {
                if (!typeToAddRemoveMethodsMapOld.ContainsKey(keyItem))
                {
                    typeToAddRemoveMethodsMapOld.Add(keyItem, addRemoveMethods);
                }
            }
            return(addRemoveMethods);
        }
Ejemplo n.º 12
0
        public static MethodInfo[] GetAsyncMethods(MethodInfo syncMethod, Type asyncInterface)
        {
            readLock.Lock();
            try
            {
                MethodInfo[] asyncMethods = DictionaryExtension.ValueOrDefault(syncToAsyncDict, syncMethod);
                if (asyncMethods != null)
                {
                    return(asyncMethods);
                }
            }
            finally
            {
                readLock.Unlock();
            }
            ParameterInfo[] parameters = syncMethod.GetParameters();

            Type[] beginTypes = new Type[parameters.Length + 2];
            for (int a = parameters.Length; a-- > 0;)
            {
                beginTypes[a] = parameters[a].ParameterType;
            }
            beginTypes[beginTypes.Length - 2] = typeof(AsyncCallback);
            beginTypes[beginTypes.Length - 1] = typeof(Object);

            String     methodName  = syncMethod.Name;
            String     beginName   = "Begin" + methodName;
            String     endName     = "End" + methodName;
            MethodInfo beginMethod = asyncInterface.GetMethod(beginName, beginTypes);

            if (beginMethod == null)
            {
                throw new ArgumentException("No method with name '" + beginName + "'" + parameters + " found");
            }
            MethodInfo endMethod = asyncInterface.GetMethod(endName, new Type[] { typeof(IAsyncResult) });

            if (endMethod == null)
            {
                throw new ArgumentException("No method with name '" + endName + "'" + typeof(IAsyncResult) + " found");
            }
            MethodInfo[] result = new MethodInfo[] { beginMethod, endMethod };
            writeLock.Lock();
            try
            {
                if (!syncToAsyncDict.ContainsKey(syncMethod)) // Some other thread might be faster here so we have to check this
                {
                    syncToAsyncDict.Add(syncMethod, result);
                }
                if (!asyncToSyncDict.ContainsKey(beginMethod))
                {
                    asyncToSyncDict.Add(beginMethod, syncMethod);
                }
            }
            finally
            {
                writeLock.Unlock();
            }
            return(result);
        }
Ejemplo n.º 13
0
        public Object GetObjectById(int id, bool checkExistence)
        {
            Object obj = DictionaryExtension.ValueOrDefault(idToObjectMap, id);

            if (obj == null && checkExistence)
            {
                throw new Exception("No object found in xml with id " + id);
            }
            return(obj);
        }
Ejemplo n.º 14
0
        public int GetIndexByPrimitive(Member primitiveMember)
        {
            int?index = DictionaryExtension.ValueOrDefault(primMemberToIndexDict, primitiveMember);

            if (!index.HasValue)
            {
                throw new ArgumentException("No index found for primitive member: " + primitiveMember);
            }
            return(index.Value);
        }
Ejemplo n.º 15
0
        public int GetIndexByRelation(Member relationMember)
        {
            int?index = DictionaryExtension.ValueOrDefault(relMemberToIndexDict, relationMember);

            if (!index.HasValue)
            {
                throw new ArgumentException("No index found for relation member: " + relationMember);
            }
            return(index.Value);
        }
Ejemplo n.º 16
0
        public sbyte GetIdIndexByMemberName(String memberName)
        {
            sbyte?index = DictionaryExtension.ValueOrDefault(memberNameToIdIndexDict, memberName);

            if (!index.HasValue)
            {
                throw new ArgumentException("No alternate id index found for member name '" + memberName + "'");
            }
            return(index.Value);
        }
Ejemplo n.º 17
0
        public ValueObjectMemberType GetValueObjectMemberType(String valueObjectMemberName)
        {
            ValueObjectMemberType?memberType = DictionaryExtension.ValueOrDefault(valueObjectMemberTypes, valueObjectMemberName);

            if (memberType == null)
            {
                memberType = ValueObjectMemberType.UNDEFINED;
            }
            return(memberType.Value);
        }
Ejemplo n.º 18
0
        protected virtual Object ResolveObjectById(IDictionary <int, Object> idToObjectMap, int id)
        {
            Object obj = DictionaryExtension.ValueOrDefault(idToObjectMap, id);

            if (obj == null)
            {
                throw new Exception("No object found with id " + id);
            }
            return(obj);
        }
Ejemplo n.º 19
0
        public static IList <T> ConvertToCollectionContract <T>(IList <T> list)
        {
            Type collectionContractType = DictionaryExtension.ValueOrDefault(listToTypeCollectionContractType, list.GetType());

            if (collectionContractType == null)
            {
                return(list);
            }
            return((IList <T>)Activator.CreateInstance(collectionContractType, list));
        }
Ejemplo n.º 20
0
        public void RegisterXmlType(Type type, String name, String namespaceString)
        {
            ParamChecker.AssertParamNotNull(type, "type");
            ParamChecker.AssertParamNotNull(name, "name");
            if (namespaceString == null)
            {
                namespaceString = String.Empty;
            }

            XmlTypeKey xmlTypeKey = new XmlTypeKey();

            xmlTypeKey.Name      = name;
            xmlTypeKey.Namespace = namespaceString;

            writeLock.Lock();
            try
            {
                Type typeToSet    = type;
                Type existingType = xmlTypeToClassMap.Get(name, namespaceString);
                if (existingType != null)
                {
                    if (type.IsAssignableFrom(existingType))
                    {
                        // Nothing else to to
                    }
                    else if (existingType.IsAssignableFrom(type))
                    {
                        typeToSet = existingType;
                    }
                    else if (typeof(IList <>).Equals(existingType) && typeof(ObservableCollection <>).Equals(type))
                    {
                        // Workaround for C# since the two collections are not assignable to eachother.
                        typeToSet = existingType;
                    }
                    else
                    {
                        throw new Exception("Error while registering '" + type.FullName + "': Unassignable type '" + existingType.FullName
                                            + "' already registered for: Name='" + name + "' Namespace='" + namespaceString + "'");
                    }
                }
                xmlTypeToClassMap.Put(name, namespaceString, typeToSet);

                IList <XmlTypeKey> xmlTypeKeys = DictionaryExtension.ValueOrDefault(classToXmlTypeMap, type);
                if (xmlTypeKeys == null)
                {
                    xmlTypeKeys = new List <XmlTypeKey>();
                    classToXmlTypeMap.Add(type, xmlTypeKeys);
                }
                xmlTypeKeys.Add(xmlTypeKey);
            }
            finally
            {
                writeLock.Unlock();
            }
        }
Ejemplo n.º 21
0
        public static MethodInfo GetSyncMethod(MethodInfo asyncBeginMethod, Type syncInterface)
        {
            readLock.Lock();
            try
            {
                MethodInfo syncMethod = DictionaryExtension.ValueOrDefault(asyncToSyncDict, asyncBeginMethod);
                if (syncMethod != null)
                {
                    return(syncMethod);
                }
            }
            finally
            {
                readLock.Unlock();
            }
            ParameterInfo[] parameters      = asyncBeginMethod.GetParameters();
            String          asyncMethodName = asyncBeginMethod.Name;
            String          syncMethodName;

            Type[] paramTypes;
            if (asyncMethodName.StartsWith("Begin"))
            {
                syncMethodName = asyncMethodName.Substring(5);
                paramTypes     = new Type[parameters.Length - 2]; // Trim last 2 arguments "IAsyncCallback" abd "Objectstate"
                for (int a = parameters.Length - 2; a-- > 0;)
                {
                    ParameterInfo parameter = parameters[a];
                    paramTypes[a] = parameter.ParameterType;
                }
            }
            else
            {
                throw new ArgumentException("AsyncMethod '" + asyncBeginMethod + "' does not seem to be a Begin-method");
            }
            MethodInfo result = syncInterface.GetMethod(syncMethodName, paramTypes);

            if (result == null)
            {
                throw new ArgumentException("No method with name '" + syncMethodName + "'" + paramTypes + " found");
            }
            writeLock.Lock();
            try
            {
                if (!asyncToSyncDict.ContainsKey(asyncBeginMethod)) // Some other thread might be faster here so we have to check this
                {
                    asyncToSyncDict.Add(asyncBeginMethod, result);
                }
            }
            finally
            {
                writeLock.Unlock();
            }
            return(result);
        }
Ejemplo n.º 22
0
        protected IDictionary <String, IModelContainer> ReadIntern(String token)
        {
            SharedDataItem sharedDataItem = DictionaryExtension.ValueOrDefault(tokenToDataDict, token);

            if (sharedDataItem == null)
            {
                return(null);
            }
            sharedDataItem.lastAccess = DateTime.Now;
            return(sharedDataItem.data);
        }
Ejemplo n.º 23
0
        public String GetValueObjectMemberName(String businessObjectMemberName)
        {
            String voMemberName = DictionaryExtension.ValueOrDefault(boToVoMemberNameMap, businessObjectMemberName);

            if (voMemberName == null)
            {
                return(businessObjectMemberName);
            }
            else
            {
                return(voMemberName);
            }
        }
Ejemplo n.º 24
0
        public void PutObjectWithId(Object obj, int id)
        {
            Object existingObj = DictionaryExtension.ValueOrDefault(idToObjectMap, id);

            if (existingObj != null)
            {
                if (existingObj != obj)
                {
                    throw new Exception("Already mapped object to id " + id + " found");
                }
                return;
            }
            idToObjectMap.Add(id, obj);
        }
Ejemplo n.º 25
0
        public IXmlTypeKey GetXmlType(Type type, bool expectExisting)
        {
            ParamChecker.AssertParamNotNull(type, "type");

            readLock.Lock();
            try
            {
                IList <XmlTypeKey> xmlTypeKeys = DictionaryExtension.ValueOrDefault(weakClassToXmlTypeMap, type);
                if (xmlTypeKeys == null)
                {
                    xmlTypeKeys = DictionaryExtension.ValueOrDefault(classToXmlTypeMap, type);
                    if (xmlTypeKeys == null)
                    {
                        Type realType = type;
                        if (typeof(IObjRef).IsAssignableFrom(type))
                        {
                            realType = typeof(IObjRef);
                        }
                        xmlTypeKeys = DictionaryExtension.ValueOrDefault(classToXmlTypeMap, realType);
                    }
                    if (xmlTypeKeys != null)
                    {
                        readLock.Unlock();
                        writeLock.Lock();
                        try
                        {
                            if (!weakClassToXmlTypeMap.ContainsKey(type))
                            {
                                weakClassToXmlTypeMap.Add(type, xmlTypeKeys);
                            }
                        }
                        finally
                        {
                            writeLock.Unlock();
                            readLock.Lock();
                        }
                    }
                }

                if ((xmlTypeKeys == null || xmlTypeKeys.Count == 0) && expectExisting)
                {
                    throw new Exception("No xml type found: Type=" + type);
                }
                return(xmlTypeKeys[0]);
            }
            finally
            {
                readLock.Unlock();
            }
        }
Ejemplo n.º 26
0
        protected MethodInfo FindMethodOnInterface(MethodInfo classMethod)
        {
            IDictionary <MethodInfo, MethodInfo> externToInternMethodDict = externToInternMethodDictTL.Value;

            MethodInfo interfaceMethod = DictionaryExtension.ValueOrDefault(externToInternMethodDict, classMethod);

            if (interfaceMethod != null)
            {
                return(interfaceMethod);
            }
            Type[]       types   = GetTypes(classMethod.GetParameters());
            MethodInfo[] methods = InterfaceType.GetMethods();
            foreach (MethodInfo method in methods)
            {
                if (!classMethod.Name.StartsWith(method.Name))
                {
                    continue;
                }
                // This is a method candidate tested by its name. The question is now how the arguments are typed
                bool            paramFails = false;
                ParameterInfo[] paramInfos = method.GetParameters();
                if (paramInfos.Length != types.Length)
                {
                    continue;
                }
                for (int a = paramInfos.Length; a-- > 0;)
                {
                    Type parameterType = paramInfos[a].ParameterType;
                    if (!types[a].Equals(parameterType))
                    {
                        paramFails = true;
                        break;
                    }
                }
                if (paramFails)
                {
                    continue;
                }
                interfaceMethod = method;
                break;
            }
            if (interfaceMethod == null)
            {
                throw new NotSupportedException("Class method: '" + classMethod + "' can not be mapped to a method of interface '" + InterfaceType + "'");
            }
            externToInternMethodDict.Add(classMethod, interfaceMethod);
            return(interfaceMethod);
        }
Ejemplo n.º 27
0
        protected override void InterceptIntern(IInvocation invocation)
        {
            MethodInfo mappedMethod = DictionaryExtension.ValueOrDefault(methodMap, invocation.Method);

            if (mappedMethod == null)
            {
                invocation.ReturnValue = invocation.Method.Invoke(extendableContainer, invocation.Arguments);
                return;
            }
            Object value = mappedMethod.Invoke(extendableContainer, invocation.Arguments);

            if (value == null && invocation.Method.Equals(providerTypeGetOne))
            {
                value = DefaultBean;
            }
            invocation.ReturnValue = value;
        }
Ejemplo n.º 28
0
        public Object Get(String key, IProperties initiallyCalledProps)
        {
            if (initiallyCalledProps == null)
            {
                initiallyCalledProps = this;
            }
            Object propertyValue = DictionaryExtension.ValueOrDefault(dictionary, key);

            if (propertyValue == null && Parent != null)
            {
                return(Parent.Get(key, initiallyCalledProps));
            }
            if (!(propertyValue is String))
            {
                return(propertyValue);
            }
            return(initiallyCalledProps.ResolvePropertyParts((String)propertyValue));
        }
Ejemplo n.º 29
0
        public virtual void AddRelationPath <R>(String relationPath) where R : class
        {
            if (InitializedRelations == null)
            {
                InitializedRelations = new Dictionary <Type, IList <String> >();
            }
            IList <String> pathNames = DictionaryExtension.ValueOrDefault(InitializedRelations, typeof(R));

            if (pathNames == null)
            {
                pathNames = new List <String>();
                InitializedRelations.Add(typeof(R), pathNames);
            }
            if (!pathNames.Contains(relationPath))
            {
                pathNames.Add(relationPath);
            }
        }
Ejemplo n.º 30
0
        public void Queue <T>(QueueGroupKey <T> queueGroupKey, T item)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    queueGroup.Queue.Add(item);
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey, new List <T>());
                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);

                queueGroup.Queue.Add(item);
                QueueIntern <T>(queueGroup);
            }
        }