public CommModule(bool crypto) { classPtr = crypto ? GetICommModuleCPro() : GetICommModuleZMQ(); IntPtr vtbl = Marshal.ReadIntPtr(classPtr, 0); var funcPtr = (CommModuleClass)Marshal.PtrToStructure(vtbl, typeof(CommModuleClass)); startFunc = (Delegates.Start)Marshal.GetDelegateForFunctionPointer(funcPtr.Start, typeof(Delegates.Start)); stopFunc = (Delegates.Stop)Marshal.GetDelegateForFunctionPointer(funcPtr.Stop, typeof(Delegates.Stop)); connectFunc = (Delegates.Connect)Marshal.GetDelegateForFunctionPointer(funcPtr.Connect, typeof(Delegates.Connect)); setQueueFunc = (Delegates.SetQueue)Marshal.GetDelegateForFunctionPointer(funcPtr.SetQueue, typeof(Delegates.SetQueue)); disconnectFunc = (Delegates.Disconnect)Marshal.GetDelegateForFunctionPointer(funcPtr.Disconnect, typeof(Delegates.Disconnect)); getLastErrorFunc = (Delegates.GetLastError)Marshal.GetDelegateForFunctionPointer(funcPtr.GetLastError, typeof(Delegates.GetLastError)); }
public CommQueue() { classPtr = GetICommQueue(); IntPtr vtbl = Marshal.ReadIntPtr(classPtr, 0); var funcPtr = (ICommQueue)Marshal.PtrToStructure(vtbl, typeof(ICommQueue)); putFunc = (Delegates.Put)Marshal.GetDelegateForFunctionPointer(funcPtr.Put, typeof(Delegates.Put)); getFunc = (Delegates.Get)Marshal.GetDelegateForFunctionPointer(funcPtr.Get, typeof(Delegates.Get)); stopFunc = (Delegates.Stop)Marshal.GetDelegateForFunctionPointer(funcPtr.Stop, typeof(Delegates.Stop)); allocFunc = (Delegates.Alloc)Marshal.GetDelegateForFunctionPointer(funcPtr.Alloc, typeof(Delegates.Alloc)); freeFunc = (Delegates.Free)Marshal.GetDelegateForFunctionPointer(funcPtr.Free, typeof(Delegates.Free)); getLastErrorFunc = (Delegates.GetLastError)Marshal.GetDelegateForFunctionPointer(funcPtr.GetLastError, typeof(Delegates.GetLastError)); }