SecurityContext.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //------------------------------------------------------------------------------
  2. // <copyright file="UnsafeNativeMethods.cs" company="Microsoft">
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. // </copyright>
  5. //------------------------------------------------------------------------------
  6. using Experimental.System.Messaging.Interop;
  7. using System;
  8. namespace Experimental.System.Messaging
  9. {
  10. public sealed class SecurityContext : IDisposable
  11. {
  12. SecurityContextHandle handle;
  13. bool disposed;
  14. internal SecurityContext(SecurityContextHandle securityContext)
  15. {
  16. handle = securityContext;
  17. }
  18. internal SecurityContextHandle Handle
  19. {
  20. get
  21. {
  22. if (disposed)
  23. throw new ObjectDisposedException(GetType().Name);
  24. return handle;
  25. }
  26. }
  27. public void Dispose()
  28. {
  29. handle.Close();
  30. disposed = true;
  31. }
  32. }
  33. }