// 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 { /// /// Provides a set of static methods for creating Disposables. /// public static class Disposable { /// /// Gets the disposable that does nothing when disposed. /// public static IDisposable Empty { get { return DefaultDisposable.Instance; } } /// /// Creates a disposable object that invokes the specified action when disposed. /// /// Action to run during the first call to . The action is guaranteed to be run at most once. /// The disposable object that runs the given action upon disposal. /// is null. public static IDisposable Create(Action dispose) { if (dispose == null) throw new ArgumentNullException(nameof(dispose)); return new AnonymousDisposable(dispose); } } }