| 12345678910111213141516171819202122232425262728293031323334 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the Apache 2.0 License.
- // See the LICENSE file in the project root for more information.
- namespace System.Reactive.Disposables
- {
- /// <summary>
- /// Provides a set of static methods for creating Disposables.
- /// </summary>
- public static class Disposable
- {
- /// <summary>
- /// Gets the disposable that does nothing when disposed.
- /// </summary>
- public static IDisposable Empty
- {
- get { return DefaultDisposable.Instance; }
- }
- /// <summary>
- /// Creates a disposable object that invokes the specified action when disposed.
- /// </summary>
- /// <param name="dispose">Action to run during the first call to <see cref="IDisposable.Dispose"/>. The action is guaranteed to be run at most once.</param>
- /// <returns>The disposable object that runs the given action upon disposal.</returns>
- /// <exception cref="ArgumentNullException"><paramref name="dispose"/> is null.</exception>
- public static IDisposable Create(Action dispose)
- {
- if (dispose == null)
- throw new ArgumentNullException("dispose");
- return new AnonymousDisposable(dispose);
- }
- }
- }
|