예제 #1
0
        internal static void VerifyArguments <TKey, TValue>(TKey key, AnalysisValueProvider <TKey, TValue> valueProvider)
            where TKey : class
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (valueProvider == null)
            {
                throw new ArgumentNullException(nameof(valueProvider));
            }
        }
예제 #2
0
 /// <summary>
 /// Provides values associated with <see cref="SyntaxTree"/> instances using the given <paramref name="computeValue"/>.
 /// </summary>
 /// <param name="computeValue">Delegate to compute the value associated with a given <see cref="SyntaxTree"/> instance.</param>
 /// <param name="syntaxTreeComparer">Optional equality comparer to determine equivalent <see cref="SyntaxTree"/> instances that have the same value.
 /// If no comparer is provided, then <see cref="SyntaxTreeComparer"/> is used by default.</param>
 public SyntaxTreeValueProvider(Func <SyntaxTree, TValue> computeValue, IEqualityComparer <SyntaxTree> syntaxTreeComparer = null)
 {
     CoreValueProvider = new AnalysisValueProvider <SyntaxTree, TValue>(computeValue, syntaxTreeComparer ?? SyntaxTreeComparer.Instance);
 }
예제 #3
0
 /// <summary>
 /// Provides custom values associated with <see cref="SourceText"/> instances using the given <paramref name="computeValue"/>.
 /// </summary>
 /// <param name="computeValue">Delegate to compute the value associated with a given <see cref="SourceText"/> instance.</param>
 /// <param name="sourceTextComparer">Optional equality comparer to determine equivalent <see cref="SourceText"/> instances that have the same value.
 /// If no comparer is provided, then <see cref="SourceTextComparer"/> is used by default.</param>
 public SourceTextValueProvider(Func <SourceText, TValue> computeValue, IEqualityComparer <SourceText> sourceTextComparer = null)
 {
     CoreValueProvider = new AnalysisValueProvider <SourceText, TValue>(computeValue, sourceTextComparer ?? SourceTextComparer.Instance);
 }
예제 #4
0
        internal override bool TryGetValueCore <TKey, TValue>(TKey key, AnalysisValueProvider <TKey, TValue> valueProvider, out TValue value)
        {
            var compilationAnalysisValueProvider = _compilationAnalysisValueProviderFactory.GetValueProvider(valueProvider);

            return(compilationAnalysisValueProvider.TryGetValue(key, out value));
        }
예제 #5
0
        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>);
        }
예제 #6
0
 public CompilationAnalysisValueProvider(AnalysisValueProvider <TKey, TValue> analysisValueProvider)
 {
     _analysisValueProvider = analysisValueProvider;
     _valueMap = new Dictionary <TKey, TValue>(analysisValueProvider.KeyComparer);
 }