public static IEnumerable <TEnum> ToEnum <TEnum>(this IPortableDeviceKeyCollection col) where TEnum : struct // enum
        {
            uint count = 0;

            col.GetCount(ref count);
            for (uint i = 0; i < count; i++)
            {
                PropertyKey key = new PropertyKey();
                col.GetAt(i, ref key);
                yield return(GetEnumFromAttrKey <TEnum>(key));
            }
        }
示例#2
0
        public static IEnumerable <PropertyKey> ToEnum(this IPortableDeviceKeyCollection col)
        {
            uint count = 0;

            col.GetCount(ref count);
            for (uint i = 0; i < count; i++)
            {
                PropertyKey key = new PropertyKey();
                col.GetAt(i, ref key);
                yield return(key);
            }
        }
示例#3
0
        public static void WriteObject(IPortableDeviceKeyCollection collection)
        {
            Trace.WriteLine("###############################");
            uint num = 0;

            collection.GetCount(ref num);
            for (uint index = 0; index < num; index++)
            {
                PropertyKey key = new PropertyKey();
                collection.GetAt(index, ref key);

                PropertyKeys propertyKey = key.GetEnumFromAttrKey <PropertyKeys>();
                Trace.WriteLine($"##### {propertyKey}");
            }
        }
示例#4
0
        public static TEnum[] ToArray <TEnum>(this IPortableDeviceKeyCollection col) where TEnum : struct // enum
        {
            uint count = 0;

            col.GetCount(ref count);
            var result = new TEnum[count];

            for (uint i = 0; i < count; i++)
            {
                PropertyKey key = new PropertyKey();
                col.GetAt(i, ref key);
                result[i] = GetEnumFromAttrKey <TEnum>(key);
            }
            return(result);
        }