Moved wrapped capabilities into its own class to reduce DataSource complexity.

This commit is contained in:
soukoku
2015-02-20 18:17:51 -05:00
parent 59e8b996de
commit b757cc4a42
14 changed files with 288 additions and 322 deletions

View File

@@ -24,17 +24,17 @@ namespace Tester.WPF
var capName = cap.ToString();
var wrapProperty = ds.GetType().GetProperty(capName);
var wrapProperty = ds.Capabilities.GetType().GetProperty(capName);
if (wrapProperty != null)
{
_wrapper = wrapProperty.GetGetMethod().Invoke(ds, null);
_wrapper = wrapProperty.GetGetMethod().Invoke(ds.Capabilities, null);
var wrapperType = _wrapper.GetType();
_getMethod = wrapperType.GetMethod("GetValues");
_getCurrentMethod = wrapperType.GetMethod("GetCurrent");
_setMethod = wrapperType.GetMethods().FirstOrDefault(m => m.Name == "SetValue");
}
var supportTest = ds.CapQuerySupport(cap);
var supportTest = ds.Capabilities.QuerySupport(cap);
if (supportTest.HasValue)
{
Supports = supportTest.Value;
@@ -55,7 +55,7 @@ namespace Tester.WPF
{
if (_getMethod == null)
{
return _ds.CapGet(Cap);
return _ds.Capabilities.GetValues(Cap);
}
return _getMethod.Invoke(_wrapper, null) as IEnumerable;
}
@@ -63,7 +63,7 @@ namespace Tester.WPF
{
if (_getMethod == null)
{
return _ds.CapGetCurrent(Cap);
return _ds.Capabilities.GetCurrent(Cap);
}
return _getCurrentMethod.Invoke(_wrapper, null);
}

View File

@@ -49,7 +49,7 @@ namespace Tester.WPF
//rc = DGControl.Status.Get(dsId, ref stat);
if (rc == ReturnCode.Success)
{
foreach (var c in DS.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o)))
foreach (var c in DS.Capabilities.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o)))
{
Caps.Add(c);
}

View File

@@ -120,7 +120,7 @@ namespace Tester.WPF
}
}, () =>
{
return _session.State == 4 && _session.CurrentSource.CapEnableDSUIOnly.GetCurrent() == BoolType.True;
return _session.State == 4 && _session.CurrentSource.Capabilities.CapEnableDSUIOnly.GetCurrent() == BoolType.True;
}));
}
}
@@ -246,9 +246,9 @@ namespace Tester.WPF
void _session_TransferReady(object sender, TransferReadyEventArgs e)
{
if (_session.CurrentSource.ICapXferMech.GetCurrent() == XferMech.File)
if (_session.CurrentSource.Capabilities.ICapXferMech.GetCurrent() == XferMech.File)
{
var formats = _session.CurrentSource.ICapImageFileFormat.GetValues();
var formats = _session.CurrentSource.Capabilities.ICapImageFileFormat.GetValues();
var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp;
var fileSetup = new TWSetupFileXfer