public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } ScopeExtension original = Interlocked.CompareExchange(ref _extensions[languageContextId.Id], extension, null); return original ?? extension; }
/// <summary> /// Sets the ScopeExtension to the provided value for the given ContextId. /// /// The extension can only be set once. The returned value is either the new ScopeExtension /// if no value was previously set or the previous value. /// </summary> public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); lock (_extensions) { if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } return _extensions[languageContextId.Id] ?? (_extensions[languageContextId.Id] = extension); } }
/// <summary> /// Sets the ScopeExtension to the provided value for the given ContextId. /// /// The extension can only be set once. The returned value is either the new ScopeExtension /// if no value was previously set or the previous value. /// </summary> public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); lock (_extensions) { if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } return(_extensions[languageContextId.Id] ?? (_extensions[languageContextId.Id] = extension)); } }
public ScopeExtension SetExtension(ContextId languageContextId, ScopeExtension extension) { ContractUtils.RequiresNotNull(extension, "extension"); if (languageContextId.Id >= _extensions.Length) { Array.Resize(ref _extensions, languageContextId.Id + 1); } ScopeExtension original = Interlocked.CompareExchange(ref _extensions[languageContextId.Id], extension, null); return(original ?? extension); }
// TODO: remove public ScopeExtension EnsureScopeExtension(Scope scope) { ContractUtils.RequiresNotNull(scope, "scope"); ScopeExtension extension = scope.GetExtension(ContextId); if (extension == null) { extension = CreateScopeExtension(scope); if (extension == null) { throw Error.MustReturnScopeExtension(); } return(scope.SetExtension(ContextId, extension)); } return(extension); }