DelegateInfo.cs 430 B

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