DelegateInfo.cs 526 B

123456789101112131415161718192021
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace ARMeilleure.Translation
  4. {
  5. class DelegateInfo
  6. {
  7. #pragma warning disable IDE0052 // Remove unread private member
  8. private readonly Delegate _dlg; // Ensure that this delegate will not be garbage collected.
  9. #pragma warning restore IDE0052
  10. public IntPtr FuncPtr { get; }
  11. public DelegateInfo(Delegate dlg)
  12. {
  13. _dlg = dlg;
  14. FuncPtr = Marshal.GetFunctionPointerForDelegate<Delegate>(dlg);
  15. }
  16. }
  17. }