public static ReadOnlyDictionaryRangeActiveExpression <TKey, TValue, TResult> Create(IReadOnlyDictionary <TKey, TValue> source, Expression <Func <TKey, TValue, TResult> > expression, ActiveExpressionOptions?options = null)
        {
            ReadOnlyDictionaryRangeActiveExpression <TKey, TValue, TResult> rangeActiveExpression;
            bool monitorCreated;
            var  key = new RangeActiveExpressionsKey(source, expression, options);

            lock (rangeActiveExpressionsAccess)
            {
                if (monitorCreated = !rangeActiveExpressions.TryGetValue(key, out rangeActiveExpression))
                {
                    rangeActiveExpression = new ReadOnlyDictionaryRangeActiveExpression <TKey, TValue, TResult>(source, expression, options, key);
                    rangeActiveExpressions.Add(key, rangeActiveExpression);
                }
                ++rangeActiveExpression.disposalCount;
            }
            if (monitorCreated)
            {
                rangeActiveExpression.Initialize();
            }
            return(rangeActiveExpression);
        }
Пример #2
0
 public static ReadOnlyDictionaryRangeActiveExpression <TKey, TValue, TResult> Create <TKey, TValue, TResult>(IReadOnlyDictionary <TKey, TValue> source, Expression <Func <TKey, TValue, TResult> > expression, ActiveExpressionOptions?options = null) => ReadOnlyDictionaryRangeActiveExpression <TKey, TValue, TResult> .Create(source, expression, options);