| 1234567891011121314151617181920212223242526272829303132 |
- // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license 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);
- }
- }
- }
|