示例#1
0
        /// <summary>
        ///     ''' List the devices of a given device type that are registered in the Profile store
        ///     ''' </summary>
        ///     ''' <param name="DeviceType">Type of devices to list</param>
        ///     ''' <returns>An ArrayList of installed devices and associated device descriptions</returns>
        ///     ''' <exception cref="Exceptions.InvalidValueException">Throw if the supplied DeviceType is empty string or
        ///     ''' null value.</exception>
        ///     ''' <remarks>
        ///     ''' Use this to find all the registered devices of a given type that are in the Profile store
        ///     ''' <para>If a DeviceType is supplied, where no device of that type has been registered before on this system,
        ///     ''' an empty list will be returned</para>
        ///     ''' </remarks>
        public ArrayList RegisteredDevices(string DeviceType)
        {
            System.Collections.Generic.SortedList <string, string> RegDevs = null;
            ArrayList RetVal = new ArrayList();

            if (string.IsNullOrEmpty(DeviceType))
            {
                TL.LogMessage("RegisteredDevices", "Empty string or Nothing supplied as DeviceType");
                throw new Exceptions.InvalidValueException("Empty string or Nothing supplied as DeviceType");
            }
            try
            {
                RegDevs = ProfileStore.EnumKeys(DeviceType + " Drivers"); // Get Key-Class pairs
            }
            catch (NullReferenceException ex)
            {
                TL.LogMessage("RegisteredDevices", "WARNING: there are no devices of type: \"" + DeviceType + "\" registered on this system");
                RegDevs = new System.Collections.Generic.SortedList <string, string>();
            }// Return an empty list
            TL.LogMessage("RegisteredDevices", "Device type: " + DeviceType + " - found " + RegDevs.Count + " devices");
            foreach (System.Collections.Generic.KeyValuePair <string, string> kvp in RegDevs)
            {
                TL.LogMessage("RegisteredDevices", "  " + kvp.Key + " - " + kvp.Value);
                RetVal.Add(new KeyValuePair(kvp.Key, kvp.Value));
            }
            return(RetVal);
        }