/// <summary> /// Reads a <see cref="AuthScopeSet"/> content from a configured /// command (created by <see cref="CreateReadCommand"/>). /// Null is returned for empty returned set. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="cmd">The reader command.</param> /// <returns>The set of scopes or null.</returns> public Task <AuthScopeSet> RawReadAuthScopeSetAsync(ISqlCallContext ctx, SqlCommand cmd) { async Task <AuthScopeSet> ReadAsync(SqlCommand c, CancellationToken t) { using (var r = await cmd.ExecuteReaderAsync().ConfigureAwait(false)) { if (!await r.ReadAsync().ConfigureAwait(false)) { return(null); } var result = new AuthScopeSet() { ScopeSetId = r.GetInt32(0) }; if (await r.NextResultAsync().ConfigureAwait(false)) { while (await r.ReadAsync().ConfigureAwait(false)) { result.Add(CreateAuthScope(r)); } } return(result); } } return(ctx[Database].ExecuteQueryAsync(cmd, ReadAsync)); }
/// <summary> /// Reads a <see cref="AuthScopeSet"/> content from a configured command. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="cmd">The reader command.</param> /// <returns>The set of scopes.</returns> public AuthScopeSet RawReadAuthScopeSet(ISqlCallContext ctx, SqlCommand cmd) { AuthScopeSet Read(SqlCommand c) { using (var r = cmd.ExecuteReader()) { if (!r.Read()) { return(null); } var result = new AuthScopeSet() { ScopeSetId = r.GetInt32(0) }; if (r.NextResult()) { while (r.Read()) { result.Add(CreateAuthScope(r)); } } return(result); } } return(ctx[Database].ExecuteQuery(cmd, Read)); }
/// <summary> /// Reads a <see cref="AuthScopeSet"/> content from a configured command. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="cmd">The reader command.</param> /// <returns>The set of scopes.</returns> public AuthScopeSet RawReadAuthScopeSet(ISqlCallContext ctx, SqlCommand cmd) { using ((cmd.Connection = ctx[Database.ConnectionString]).EnsureOpen()) using (var r = cmd.ExecuteReader()) { var result = new AuthScopeSet(); if (r.Read()) { result.ScopeSetId = r.GetInt32(0); } if (r.NextResult()) { while (r.Read()) { result.Add(CreateAuthScope(r)); } } return(result); } }
/// <summary> /// Reads a <see cref="AuthScopeSet"/> content from a configured /// command (created by <see cref="CreateReadCommand"/>). /// Null is returned for empty returned set. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="cmd">The reader command.</param> /// <returns>The set of scopes or null.</returns> public async Task <AuthScopeSet> RawReadAuthScopeSetAsync(ISqlCallContext ctx, SqlCommand cmd) { using (await(cmd.Connection = ctx[Database.ConnectionString]).EnsureOpenAsync().ConfigureAwait(false)) using (var r = await cmd.ExecuteReaderAsync().ConfigureAwait(false)) { if (!await r.ReadAsync().ConfigureAwait(false)) { return(null); } var result = new AuthScopeSet() { ScopeSetId = r.GetInt32(0) }; if (await r.NextResultAsync().ConfigureAwait(false)) { while (await r.ReadAsync().ConfigureAwait(false)) { result.Add(CreateAuthScope(r)); } } return(result); } }
/// <summary> /// Sets the scopes of a scope set: existing scopes that do not appear in <paramref name="set"/> /// are removed. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="actorId">The acting actor identifier.</param> /// <param name="set">The new scope set value.</param> /// <returns>The awaitable.</returns> public virtual Task SetScopesAsync(ISqlCallContext ctx, int actorId, AuthScopeSet set) { return(DoAddOrUpdateScopesAsync(ctx, actorId, set.ScopeSetId, set.ToString(), true, 'W', true)); }
/// <summary> /// Sets the scopes of a scope set: existing scopes that do not appear in <paramref name="set"/> /// are removed. /// </summary> /// <param name="ctx">The call context.</param> /// <param name="actorId">The acting actor identifier.</param> /// <param name="set">The new scope set value.</param> public virtual void SetScopes(ISqlCallContext ctx, int actorId, AuthScopeSet set) { DoAddScopes(ctx, actorId, set.ScopeSetId, set.ToString(), true, 'W', true); }