Esempio n. 1
0
        internal Device(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
        {
            if (deviceClass == null)
            {
                throw new ArgumentNullException(nameof(deviceClass));
            }

            if (deviceInfoData == null)
            {
                throw new ArgumentNullException(nameof(deviceInfoData));
            }

            DeviceClass    = deviceClass;
            DeviceInfoData = deviceInfoData;
            Path           = path; // may be null
            Index          = index;

            _class            = new Lazy <string>(GetClass);
            _classGuid        = new Lazy <string>(GetClassGuid);
            _description      = new Lazy <string>(GetDescription);
            _friendlyName     = new Lazy <string>(GetFriendlyName);
            _capabilities     = new Lazy <DeviceCapabilities>(GetCapabilities);
            _isUsb            = new Lazy <bool>(GetIsUsb);
            _parent           = new Lazy <Device>(GetParent);
            _removableDevices = new Lazy <DeviceCollection>(GetRemovableDevices);
        }
Esempio n. 2
0
 internal Volume(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index, ILogger logger)
     : base(deviceClass, deviceInfoData, path, index, logger)
 {
     _volumeName   = new Lazy <string>(GetVolumeName);
     _logicalDrive = new Lazy <string>(GetLogicalDrive);
     _disks        = new Lazy <DiskCollection>(GetDisks);
     _diskNumbers  = new Lazy <int[]>(GetDiskNumbers);
 }
Esempio n. 3
0
        private Device GetParent()
        {
            uint parentDevInst = 0;
            int  hr            = Native.CM_Get_Parent(ref parentDevInst, DeviceInfoData.devInst, 0);

            if (hr == 0)
            {
                Native.SP_DEVINFO_DATA info = DeviceClass.GetInfo(parentDevInst);
                return(new Device(DeviceClass, info, null, -1));
            }

            return(null);
        }
Esempio n. 4
0
        internal Device(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
        {
            if (deviceClass == null)
            {
                throw new ArgumentNullException("deviceClass");
            }

            if (deviceInfoData == null)
            {
                throw new ArgumentNullException("deviceInfoData");
            }

            _deviceClass    = deviceClass;
            _path           = path; // may be null
            _deviceInfoData = deviceInfoData;
            _index          = index;
        }
Esempio n. 5
0
 private DeviceCapabilities GetCapabilities()
 {
     return((DeviceCapabilities)DeviceClass.GetProperty(DeviceInfoData, Native.SPDRP_CAPABILITIES, 0));
 }
Esempio n. 6
0
 private string GetFriendlyName()
 {
     return(DeviceClass.GetProperty(DeviceInfoData, Native.SPDRP_FRIENDLYNAME, null));
 }
Esempio n. 7
0
 private string GetDescription()
 {
     return(DeviceClass.GetProperty(DeviceInfoData, Native.SPDRP_DEVICEDESC, null));
 }
Esempio n. 8
0
 private string GetClassGuid()
 {
     return(DeviceClass.GetProperty(DeviceInfoData, Native.SPDRP_CLASSGUID, null));
 }
Esempio n. 9
0
 internal Disk(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index, ILogger logger)
     : base(deviceClass, deviceInfoData, path, index, logger)
 {
     _diskNumber = new Lazy <int>(GetDiskNumber);
 }
Esempio n. 10
0
 internal virtual Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
 {
     return(new Device(deviceClass, deviceInfoData, path, index));
 }
Esempio n. 11
0
 internal Volume(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
     : base(deviceClass, deviceInfoData, path, index)
 {
 }
Esempio n. 12
0
 internal override Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
 {
     return(new Volume(deviceClass, deviceInfoData, path, index));
 }