public CompilationAnalysisValueProvider <TKey, TValue> GetValueProvider <TKey, TValue>(
            AnalysisValueProvider <TKey, TValue> analysisSharedStateProvider
            ) where TKey : class
        {
            if (_lazySharedStateProviderMap == null)
            {
                Interlocked.CompareExchange(
                    ref _lazySharedStateProviderMap,
                    new Dictionary <object, object>(),
                    null
                    );
            }

            object value;

            lock (_lazySharedStateProviderMap)
            {
                if (
                    !_lazySharedStateProviderMap.TryGetValue(analysisSharedStateProvider, out value)
                    )
                {
                    value = new CompilationAnalysisValueProvider <TKey, TValue>(
                        analysisSharedStateProvider
                        );
                    _lazySharedStateProviderMap[analysisSharedStateProvider] = value;
                }
            }

            return(value as CompilationAnalysisValueProvider <TKey, TValue>);
        }
Exemple #2
0
        internal override bool TryGetValueCore <TKey, TValue>(TKey key, AnalysisValueProvider <TKey, TValue> valueProvider, out TValue value)
        {
            CompilationAnalysisValueProvider <TKey, TValue> compilationAnalysisValueProvider = _compilationAnalysisValueProviderFactory.GetValueProvider(valueProvider);

            return(compilationAnalysisValueProvider.TryGetValue(key, out value));
        }