public static IEnumerable <string> ToStrings(this IPortableDevicePropVariantCollection col) { uint count = 0; col.GetCount(ref count); for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); yield return(PropVariant.FromValue(val)); } }
public static IEnumerable <TEnum> ToEnum <TEnum>(this IPortableDevicePropVariantCollection col) where TEnum : struct // enum { uint count = 0; col.GetCount(ref count); for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); yield return(GetEnumFromAttrGuid <TEnum>(PropVariant.FromValue(val))); } }
public static Guid[] ToGuid(this IPortableDevicePropVariantCollection col) { uint count = 0; col.GetCount(ref count); var result = new Guid[count]; for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); result[i] = PropVariant.FromValue(val); } return(result); }
public static TEnum[] ToArray <TEnum>(this IPortableDevicePropVariantCollection col) where TEnum : struct // enum { uint count = 0; col.GetCount(ref count); var result = new TEnum[count]; for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); result[i] = GetEnumFromAttrGuid <TEnum>(PropVariant.FromValue(val)); } return(result); }
public IEnumerable <PropVariant> GetPropVariants(PropertyKey key) { object obj = null; this.result.GetIUnknownValue(key, out obj); var col = obj as IPortableDevicePropVariantCollection; uint count = 0; col.GetCount(ref count); for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); yield return(PropVariant.FromValue(val)); } }
public PropVariant[] GetPropVariants(PropertyKey key) { if (!this.result.TryGetIUnknownValue(key, out object obj)) { return(new PropVariant[0]); } var col = obj as IPortableDevicePropVariantCollection; uint count = 0; col.GetCount(ref count); var result = new PropVariant[count]; for (uint i = 0; i < count; i++) { PROPVARIANT val = new PROPVARIANT(); col.GetAt(i, ref val); result[i] = PropVariant.FromValue(val); } return(result); }