示例#1
0
 /// <summary>
 /// Create a new DeviceHandlerBase
 /// </summary>
 /// <param name="deviceDescriptor">The descriptor describing the device</param>
 /// <param name="deviceEmptyHandler">An eventhandler to fire when the device can be removed</param>
 /// <param name="bindModeHandler">The event handler to fire when there is a Bind Mode event</param>
 protected DeviceHandlerBase(DeviceDescriptor deviceDescriptor, EventHandler <DeviceDescriptor> deviceEmptyHandler, EventHandler <BindModeUpdate> bindModeHandler)
 {
     _processUpdates     = ProcessSubscriptionModeUpdates;
     BindModeUpdate      = bindModeHandler;
     DeviceDescriptor    = deviceDescriptor;
     _deviceEmptyHandler = deviceEmptyHandler;
     SubHandler          = new SubscriptionHandler(deviceDescriptor, OnDeviceEmpty, CallbackHandler);
 }
示例#2
0
 /// <inheritdoc />
 /// <summary>
 /// Enables or disables Bind Mode
 /// </summary>
 /// <param name="mode"></param>
 public void SetDetectionMode(DetectionMode mode)
 {
     DetectionMode = mode;
     if (mode == DetectionMode.Bind)
     {
         _processUpdates = ProcessBindModeUpdates;
     }
     else
     {
         _processUpdates = ProcessSubscriptionModeUpdates;
     }
     // If switching from Bind Mode back to Subscription mode and there are no Bindings, fire the empty handler (eg to kill the PollThread)
     if (mode == DetectionMode.Subscription && SubHandler.Count() == 0)
     {
         OnDeviceEmpty(this, DeviceDescriptor);
     }
 }