Пример #1
0
        private IKeyValueResultAccessor <TKey, TValue> CreateAddInsertCondition(Func <KeyValuePair <TKey, TValue>, bool> condition,
                                                                                IResultSetterManager <KeyValuePair <TKey, TValue> > manager)
        {
            var c = new KeyValueCondition <TKey, TValue>(condition);

            // Go through all of the existing items to see if this condition
            // has already been met. Otherwise the caller could potentially
            // wait forever.
            bool conditionNotMet = true;

            foreach (KeyValuePair <TKey, TValue> kvp in dict)
            {
                if (c.TrySetResult(kvp))
                {
                    conditionNotMet = false;
                }
            }

            // The condition was not met by any of the items in the dictionary.
            // Add the condition to the manager to be monitored.
            if (conditionNotMet)
            {
                manager.Add(c);
            }

            return(c);
        }
Пример #2
0
        private static IKeyValueResultAccessor <TKey, TValue> CreateCondition(Func <KeyValuePair <TKey, TValue>, bool> condition,
                                                                              IResultSetterManager <KeyValuePair <TKey, TValue> > manager)
        {
            var c = new KeyValueCondition <TKey, TValue>(condition);

            manager.Add(c);
            return(c);
        }