-
-
Save stevetalkscode/929a5278b6613e3c11d291c7ec0c5e89 to your computer and use it in GitHub Desktop.
Example of using restricted interface to hide Dispose method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StartUp | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddSingleton<IDoSomething, SomeDisposable>(); | |
} | |
} | |
public interface IDoSomething | |
{ | |
void DoSomething(); | |
} | |
public class SomeDisposable : IDoSomething, IDisposable | |
{ | |
public void DoSomething() | |
{ | |
} | |
void IDisposable.Dispose() | |
{ | |
// dispose unmanaged resources here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment