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)));
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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));
            }
        }
Esempio n. 6
0
        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);
        }