You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

SafeLLamaHandleBase.cs 737 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace LLama.Native
  4. {
  5. /// <summary>
  6. /// Base class for all llama handles to native resources
  7. /// </summary>
  8. public abstract class SafeLLamaHandleBase
  9. : SafeHandle
  10. {
  11. private protected SafeLLamaHandleBase()
  12. : base(IntPtr.Zero, ownsHandle: true)
  13. {
  14. }
  15. private protected SafeLLamaHandleBase(IntPtr handle, bool ownsHandle)
  16. : base(IntPtr.Zero, ownsHandle)
  17. {
  18. SetHandle(handle);
  19. }
  20. /// <inheritdoc />
  21. public override bool IsInvalid => handle == IntPtr.Zero;
  22. /// <inheritdoc />
  23. public override string ToString() => handle.ToString();
  24. }
  25. }