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)); } }
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); } }
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}"); } }
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); }