View on GitHub

SARAFF SOFTWARE

All products / Saraff.Twain.DS / Contents

Adding new capabilities

To create new capability, you must declare a class that derives from the DataSourceCapability (OneDataSourceCapability, ArrayDataSourceCapability, EnumDataSourceCapability).

// Standard a capability.
[DataSourceCapability(
    TwCap.FeederEnabled, 
    TwType.Bool, 
    SupportedOperations=TwQC.Get|TwQC.GetCurrent|TwQC.GetDefault|TwQC.Set|TwQC.Reset, 
    Get=TwOn.Enum)]
internal sealed class FeederEnabledDataSourceCapability:EnumDataSourceCapability<bool> {
    // ...
}
//Custom a capability.
[DataSourceCapability(
    (TwCap)0x8001, 
    TwType.Int16, 
    SupportedOperations=TwQC.Get|TwQC.GetCurrent|TwQC.GetDefault|TwQC.Set, 
    Get=TwOn.One)]
internal sealed class FeederXferCountDataSourceCapability:OneDataSourceCapability<short> {
}

Define relationship the capability to a DS.

[Capability(typeof(Capabilities.FeederEnabledDataSourceCapability))]
public abstract class DataSource:IDataSource {
    // ...
}
[Capability(typeof(Capabilities.FeederXferCountDataSourceCapability))]
public sealed class ScreenDataSource:BitmapDataSource {
    // ...
}