public CompilationAnalysisValueProvider( AnalysisValueProvider <TKey, TValue> analysisValueProvider ) { _analysisValueProvider = analysisValueProvider; _valueMap = new Dictionary <TKey, TValue>(analysisValueProvider.KeyComparer); }
internal override bool TryGetValueCore <TKey, TValue>(TKey key, AnalysisValueProvider <TKey, TValue> valueProvider, [MaybeNull][NotNullWhen(true)] out TValue value) #pragma warning restore CS8765 { var compilationAnalysisValueProvider = _compilationAnalysisValueProviderFactory.GetValueProvider(valueProvider); return(compilationAnalysisValueProvider.TryGetValue(key, out value)); }
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>); }
/// <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 ); }
/// <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 ); }
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)); } }
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)); }