mirror of
https://github.com/soukoku/ntwain.git
synced 2026-01-26 13:39:47 +08:00
Added GetLabel/GetHelp for caps as experiment.
This commit is contained in:
@@ -76,10 +76,10 @@ namespace Net5Console
|
||||
|
||||
var caps = session.Capabilities;
|
||||
Console.WriteLine("Device supports these caps:");
|
||||
//foreach (var cap in caps.Keys.OrderBy(c => c))
|
||||
//{
|
||||
// Console.WriteLine($"\t{cap}: {caps[cap].Supports}");
|
||||
//}
|
||||
foreach (var cap in caps.CAP_SUPPORTEDCAPS.GetValues())
|
||||
{
|
||||
WriteCapInfo(caps, cap);
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
//if (caps.TryGetValue(CAP.ICAP_PIXELTYPE, out CapWrapper wrapper))
|
||||
@@ -123,5 +123,18 @@ namespace Net5Console
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void WriteCapInfo(Capabilities caps, CAP cap)
|
||||
{
|
||||
// use reflection due to generics
|
||||
var propInfo = typeof(Capabilities).GetProperty(cap.ToString());
|
||||
if (propInfo == null) return;
|
||||
|
||||
var capWrapper = propInfo.GetValue(caps);
|
||||
var label = (string)capWrapper.GetType().GetMethod(nameof(CapWrapper<int>.GetLabel)).Invoke(capWrapper, null);
|
||||
var supports = (TWQC)capWrapper.GetType().GetMethod(nameof(CapWrapper<int>.QuerySupport)).Invoke(capWrapper, null);
|
||||
|
||||
Console.WriteLine($"\t{label ?? cap.ToString()}: {supports}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user