using System; using Microsoft.Toolkit.Diagnostics; namespace Barotrauma.LuaCs.Services; /// /// Defines a service that can be reset to it's post-constructor state and reused without needing to be disposed. /// Intended for persistent services. /// public interface IReusableService : IService { /// /// Returns the service to its original state (post-instantiation). /// Allows a service instance to be reused without disposing of the instance. /// FluentResults.Result Reset(); } /// /// Base interface inherited by all services. /// /// Throws exception if `IsDisposed` return true. public interface IService : IDisposable { bool IsDisposed { get; } public void CheckDisposed() { if (IsDisposed) ThrowHelper.ThrowObjectDisposedException($"Tried to call method on disposed object '{this.GetType().Name}'!"); } static void CheckDisposed(IService service) { if (service.IsDisposed) ThrowHelper.ThrowObjectDisposedException($"Tried to call method on disposed object '{service.GetType().Name}'!"); } }