Esempio n. 1
0
 /// <summary>
 /// Throws an <see cref="ObjectDisposedException"/> if this enumerator has been disposed.
 /// </summary>
 private void ThrowIfDisposed()
 {
     if (_disposed)
     {
         Requires.FailObjectDisposed(this);
     }
 }
 /// <summary>
 /// Returns the recyclable value if it hasn't been reclaimed already.
 /// </summary>
 /// <typeparam name="TCaller">The type of renter of the object.</typeparam>
 /// <param name="caller">The renter of the object.</param>
 /// <returns>The rented object.</returns>
 /// <exception cref="ObjectDisposedException">Thrown if <paramref name="caller"/> is no longer the renter of the value.</exception>
 internal T Use <TCaller>(ref TCaller caller)
     where TCaller : struct, ISecurePooledObjectUser
 {
     if (!IsOwned(ref caller))
     {
         Requires.FailObjectDisposed(caller);
     }
     return(_value);
 }
            /// <summary>
            /// Throws an <see cref="ObjectDisposedException"/> if this enumerator has been disposed.
            /// </summary>
            internal void ThrowIfDisposed()
            {
                // Since this is a struct, copies might not have been marked as disposed.
                // But the stack we share across those copies would know.
                // This trick only works when we have a non-null stack.
                // For enumerators of empty collections, there isn't any natural
                // way to know when a copy of the struct has been disposed of.

                if (_root == null || (_stack != null && !_stack.IsOwned(ref this)))
                {
                    Requires.FailObjectDisposed(this);
                }
            }