Exemplo n.º 1
0
        public HandlerDIR(PXCMSenseManager sm, Handler handler)
        {
            this.sm      = sm;
            this.handler = handler;
            HandlerSet handlerSet = new HandlerSet();

            gchandles = new List <GCHandle>();

            if (handler.onConnect != null)
            {
                OnConnectDIRDelegate dir = new OnConnectDIRDelegate(OnConnect);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onConnect = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onModuleSetProfile != null)
            {
                OnModuleSetProfileDIRDelegate dir = new OnModuleSetProfileDIRDelegate(OnModuleSetProfile);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onModuleSetProfile = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onModuleProcessedFrame != null)
            {
                OnModuleProcessedFrameDIRDelegate dir = new OnModuleProcessedFrameDIRDelegate(OnModuleProcessedFrame);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onModuleProcessedFrame = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onNewSample != null)
            {
                OnNewSampleDIRDelegate dir = new OnNewSampleDIRDelegate(OnNewSample);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onNewSample = Marshal.GetFunctionPointerForDelegate(dir);
            }
            if (handler.onStatus != null)
            {
                OnStatusDIRDelegate dir = new OnStatusDIRDelegate(OnStatus);
                gchandles.Add(GCHandle.Alloc(dir));
                handlerSet.onStatus = Marshal.GetFunctionPointerForDelegate(dir);
            }

            dirUnmanaged = PXCMSenseManager_AllocHandlerDIR(handlerSet);
        }
Exemplo n.º 2
0
            public HandlerDIR(PXCMSenseManager sm, Handler handler)
            {
                this.sm = sm;
                this.handler = handler;
                HandlerSet handlerSet = new HandlerSet();
                gchandles = new List<GCHandle>();

                if (handler.onConnect != null)
                {
                    OnConnectDIRDelegate dir = new OnConnectDIRDelegate(OnConnect);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onConnect = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onModuleSetProfile != null)
                {
                    OnModuleSetProfileDIRDelegate dir = new OnModuleSetProfileDIRDelegate(OnModuleSetProfile);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onModuleSetProfile = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onModuleProcessedFrame != null)
                {
                    OnModuleProcessedFrameDIRDelegate dir = new OnModuleProcessedFrameDIRDelegate(OnModuleProcessedFrame);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onModuleProcessedFrame = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onNewSample != null)
                {
                    OnNewSampleDIRDelegate dir = new OnNewSampleDIRDelegate(OnNewSample);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onNewSample = Marshal.GetFunctionPointerForDelegate(dir);
                }
                if (handler.onStatus != null)
                {
                    OnStatusDIRDelegate dir = new OnStatusDIRDelegate(OnStatus);
                    gchandles.Add(GCHandle.Alloc(dir));
                    handlerSet.onStatus = Marshal.GetFunctionPointerForDelegate(dir);
                }

                dirUnmanaged = PXCMSenseManager_AllocHandlerDIR(handlerSet);
            }