Пример #1
0
        /// <summary>
        /// Constructor for DeviceStatusMonitor.  Specifies
        /// the class of notifications desired and whether
        /// notifications should be fired for already-attached
        /// devices.
        /// </summary>
        /// <param name="deviceClass">
        /// Device class to monitor.
        /// </param>
        /// <param name="notifyAlreadyConnectedDevices">
        /// Set to true to receive notifiations for devices
        /// which were attached before we started monitoring;
        /// set to false to see new events only.
        /// </param>
        public DeviceStatusMonitor(DeviceClass deviceClass, bool notifyAlreadyConnectedDevices)
        {
            object[] attribs = deviceClass.GetType().GetField(deviceClass.ToString()).GetCustomAttributes(typeof(DeviceClassAtrribute), false);
            if ((attribs == null) || (attribs.Length != 1))
            {
                throw new ArgumentException("Unknown Device Class");
            }

            DeviceClassAtrribute dca = attribs[0] as DeviceClassAtrribute;

            m_deviceClass = dca.Guid;
            m_fAll        = notifyAlreadyConnectedDevices;
        }