/// <summary>
        /// Creates a scope for the given <see cref="DataLoaderContext"/>.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="completeOnDisposal">Configures whether to complete the context when the scope is disposed of. </param>
        internal DataLoaderScope(DataLoaderContext context, bool completeOnDisposal)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _completeOnDisposal = completeOnDisposal;
            _loadCtx            = context;
            _prevLoadCtx        = DataLoaderContext.Current;
            DataLoaderContext.SetCurrentContext(_loadCtx);
        }
        /// <summary>
        /// Marks the end of this scope and the point at which pending loaders will be fired.
        /// </summary>
        public void Dispose()
        {
#if NETSTANDARD1_3
            if (_loadCtx != DataLoaderContext.Current)
            {
                throw new InvalidOperationException("This context for this scope does not match the current context");
            }
#endif

            if (_completeOnDisposal)
            {
                _loadCtx.Complete();
            }
            DataLoaderContext.SetCurrentContext(_prevLoadCtx);
        }