Пример #1
0
		private void EnumVolumes(IEnumVdsObject volumeEnum) {
			object iface;
			int fetched;
			while(0 == volumeEnum.Next(1, out iface, out fetched)) {
				var volume = iface as IVdsVolume;
				VdsVolumeProperties properties;
				Marshal.ThrowExceptionForHR(volume.GetProperties(out properties));

				var volumeMF = volume as IVdsVolumeMF;
			}
		}
Пример #2
0
		private void EnumDisks(IEnumVdsObject diskEnum) {
			object iface;
			int fetched;
			while(0 == diskEnum.Next(1, out iface, out fetched)) {
				var disk = iface as IVdsDisk;
				VdsDiskProperties properties;
				Marshal.ThrowExceptionForHR(disk.GetProperties(out properties));

				Debug.WriteLine($"{properties.FriendlyName} {properties.DiskGuid} {properties.Status}");

            }  
		}
Пример #3
0
        private void EnumDisks(IEnumVdsObject diskEnum)
        {
            object iface;
            int fetched;
            while(0 == diskEnum.Next(1, out iface, out fetched)) {
                var disk = iface as IVdsDisk;
                VdsDiskProperties properties;
                Marshal.ThrowExceptionForHR(disk.GetProperties(out properties));

                Debug.WriteLine($"{properties.FriendlyName} {properties.DiskGuid} {properties.Status}");

            }
        }
Пример #4
0
		private void EnumPacks(IEnumVdsObject packEnum) {
			object iface;
			int fetched;
			while(0 == packEnum.Next(1, out iface, out fetched)) {
				var pack = iface as IVdsPack;
				IEnumVdsObject diskEnum;
				Marshal.ThrowExceptionForHR(pack.QueryDisks(out diskEnum));

				EnumDisks(diskEnum);

				IEnumVdsObject volumeEnum;
				Marshal.ThrowExceptionForHR(pack.QueryVolumes(out volumeEnum));
				EnumVolumes(volumeEnum);
			}
		}
Пример #5
0
        private void EnumPacks(IEnumVdsObject packEnum)
        {
            object iface;
            int fetched;
            while(0 == packEnum.Next(1, out iface, out fetched)) {
                var pack = iface as IVdsPack;
                IEnumVdsObject diskEnum;
                Marshal.ThrowExceptionForHR(pack.QueryDisks(out diskEnum));

                EnumDisks(diskEnum);

                IEnumVdsObject volumeEnum;
                Marshal.ThrowExceptionForHR(pack.QueryVolumes(out volumeEnum));
                EnumVolumes(volumeEnum);
            }
        }
Пример #6
0
        public static IEnumerable <T> EnumerateObjects <T>(IEnumVdsObject enumobject) where T : class
        {
            uint count;

            do
            {
                enumobject.Next(1, out IUnknown unknown, out count);
                if (count > 0)
                {
                    T o;
                    try
                    {
                        o = (T)unknown;
                    }
                    catch
                    {
                        throw new InvalidCastException("不支持的类型");
                    }
                    yield return(o);
                }
            } while (count > 0);
            enumobject.Reset();
        }
Пример #7
0
 public Enumerator(IEnumVdsObject vdsEnumerator, IVdsService vdsService)
 {
     this.vdsEnumerator = vdsEnumerator;
     this.vdsService    = vdsService;
 }
Пример #8
0
        private void EnumVolumes(IEnumVdsObject volumeEnum)
        {
            object iface;
            int fetched;
            while(0 == volumeEnum.Next(1, out iface, out fetched)) {
                var volume = iface as IVdsVolume;
                VdsVolumeProperties properties;
                Marshal.ThrowExceptionForHR(volume.GetProperties(out properties));

                var volumeMF = volume as IVdsVolumeMF;
            }
        }