/// <summary> /// Saves a value using into context using the specified key. /// </summary> /// <param name="key">The key to use when storing/retrieving the value.</param> /// <param name="value">The value to be stored.</param> public void SetValue(string key, object value) { if (HttpContext.Current != null) { HttpContext.Current.Items[key] = value; } else { if (_next != null) { // Pass call through to the secondary context storage _next.SetValue(key, value); } else { throw new NullReferenceException( "HttpContext.Current is null and no secondary IContextStorage was provided (useful in situations where context needs to be passed from HttpContext to worker threads in an ASP.NET application)."); } } }
/// <summary> /// Sets the <see cref="SnapshotContext" /> for the current API request. /// </summary> /// <param name="snapshotContext">The snapshot context to be set.</param> public void SetSnapshotContext(SnapshotContext snapshotContext) { _contextStorage.SetValue(SnapshotContextKeyName, snapshotContext); }
/// <inheritdoc cref="IAuthorizationFilterContextProvider.SetFilterContext" /> public void SetFilterContext(IReadOnlyList <AuthorizationStrategyFiltering> filters) { // Store the filters into context _contextStorage.SetValue(FilterContextKeyName, filters); }
public void SetInstanceId(string instanceId) { contextStorage.SetValue(InstanceIdContextKey, instanceId); }
public void SetSchoolYear(int schoolYear) { contextStorage.SetValue(SchoolYearContextKey, schoolYear); }
public void SetApiKeyContext(ApiKeyContext apiKeyContext) { _contextStorage.SetValue(ApiKeyContextKeyName, apiKeyContext); }
public void SetResourceUris(string[] resourceUris) { _contextStorage.SetValue(AuthorizationContextKeys.Resource, resourceUris); }