示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DotRas.RasDevice"/> class.
 /// </summary>
 /// <param name="name">The name of the device.</param>
 /// <param name="deviceType">The type of the device.</param>
 private RasDevice(string name, RasDeviceType deviceType)
 {
     this.Name = name;
     this.DeviceType = deviceType;
 }
示例#2
0
        public static RasDevice GetDeviceByName(string name, RasDeviceType deviceType, bool exactMatchOnly)
        {
            if (name == null)
            {
                ThrowHelper.ThrowArgumentNullException("name");
            }

            RasDevice retval = null;

            foreach (RasDevice device in RasDevice.GetDevices())
            {
                if (device.DeviceType == deviceType && ((!exactMatchOnly && device.Name.ToLower(CultureInfo.CurrentCulture).Contains(name.ToLower(CultureInfo.CurrentCulture))) || (exactMatchOnly && string.Compare(name, device.Name, false, CultureInfo.CurrentCulture) == 0)))
                {
                    retval = device;
                    break;
                }
            }

            return retval;
        }
示例#3
0
        public static ReadOnlyCollection<RasDevice> GetDevicesByType(RasDeviceType deviceType)
        {
            Collection<RasDevice> tempCollection = new Collection<RasDevice>();

            foreach (RasDevice device in RasDevice.GetDevices())
            {
                if (device.DeviceType == deviceType)
                {
                    tempCollection.Add(device);
                }
            }

            return new ReadOnlyCollection<RasDevice>(tempCollection);
        }
示例#4
0
 public static RasDevice GetDeviceByName(string name, RasDeviceType deviceType)
 {
     return RasDevice.GetDeviceByName(name, deviceType, false);
 }
示例#5
0
        /// <summary>
        /// Creates a new device. WARNING: This method does not guarantee the hardware will be installed.
        /// </summary>
        /// <param name="name">Required. The name of the device.</param>
        /// <param name="deviceType">Required. The <see cref="DotRas.RasDeviceType"/> indicating the type of device.</param>
        /// <remarks>
        /// This method essentially creates hardware on machines that may not exist and is exposed due to problems when hardware is installed and not recognized immediately by the remote access service. Using this method does not guarantee the hardware will be installed and may cause the machine to crash when the entry is dialed.
        /// </remarks>
        /// <returns>A new <see cref="DotRas.RasDevice"/> object.</returns>
        /// <exception cref="System.ArgumentException"><paramref name="deviceType"/> is an empty string or null reference (<b>Nothing</b> in Visual Basic).</exception>
        /// <exception cref="System.ArgumentNullException"><paramref name="name"/> is a null reference (<b>Nothing</b> in Visual Basic).</exception>
        public static RasDevice Create(string name, RasDeviceType deviceType)
        {
            if (name == null)
            {
                ThrowHelper.ThrowArgumentNullException("name");
            }

            return new RasDevice(name, deviceType);
        }