private OperationRegistrationScope GetCurrentOrParentOperationRegistrationScope() { var scope = GetCurrentScope(); if (scope == null) { return(null); } var result = scope as OperationRegistrationScope; if (result != null) { return(result); } var list = new ICompletableScope[scopes.Count]; scopes.CopyTo(list, 0); for (int i = list.Length - 2; i >= 0; i--) { result = list[i] as OperationRegistrationScope; if (result != null) { return(result); } } throw new InvalidOperationException(Strings.ExNoOperationRegistrationScope); }
internal void RemoveCurrentScope(ICompletableScope scope) { if (scopes.TailOrDefault != scope) { throw new InvalidOperationException(Strings.ExInvalidScopeDisposalOrder); } scopes.ExtractTail(); }
private async ValueTask Prepare(bool executeAsync) { enumerationScope = context.BeginEnumeration(); enumerated = context.GetValue <bool>(provider, enumerationMarker); if (!enumerated) { provider.OnBeforeEnumerate(context); context.SetValue(provider, enumerationMarker, true); } try { dataReader = executeAsync ? await provider.OnEnumerateAsync(context, token).ConfigureAwait(false) : provider.OnEnumerate(context); if (isGreedy && !dataReader.IsInMemory) { var tuples = new List <Tuple>(); if (executeAsync) { await using (dataReader.ConfigureAwait(false)) { while (await dataReader.MoveNextAsync().ConfigureAwait(false)) { tuples.Add(dataReader.Current); } } } else { using (dataReader) { while (dataReader.MoveNext()) { tuples.Add(dataReader.Current); } } } dataReader = new DataReader(tuples); } } catch { FinishEnumeration(true); throw; } state = State.Prepared; }
// Constructors internal OperationRegistry(Session session) { Session = session; blockingScope = new BlockingOperationRegistrationScope(this); }
internal ICompletableScope SetCurrentScope(ICompletableScope scope) { scopes.AddTail(scope); return(scope); }
// Constructors public OperationRegistrationScope(OperationRegistry owner, OperationType operationType, ICompletableScope currentScope) { Owner = owner; OperationType = operationType; IsOutermost = currentScope == null; oldIsSystemOperationRegistrationEnabled = owner.IsSystemOperationRegistrationEnabled; if ((operationType & OperationType.System) == OperationType.System) { owner.IsSystemOperationRegistrationEnabled = false; } }