Can you either upgrade the indexer to use GetField, or
provide a GetField function. The indexer could look like
this:
public object this[ string name ]
{
get {
if ( (PropertyInfo p = GetPropertyInfo( name )) !=
null )
return p.GetValue( Control, null );
else (FieldInfo f = GetFieldInfo( name )) != null )
return f.GetValue( Control, null );
else // or return null
throw new Exception( "not found" );
}
set
{
if ( (PropertyInfo p = GetPropertyInfo( name )) != null )
return p.SetValue( Control, value, null );
else (FieldInfo f = GetFieldInfo( name )) != null )
return f.SetValue( Control, value, null );
else // or return null
throw new Exception( "not found" );
EndCurrentEdit( name );
}
}
private PropertyInfo GetPropertyInfo( string
propertyName )
{
return Control.GetType().GetProperty( propertyName,
BindingFlags.Instance | BindingFlags.Public |
BindingFlags.NonPublic );
}
private FieldInfo GetFieldInfo( string propertyName )
{
return Control.GetType().GetField( propertyName,
BindingFlags.Instance | BindingFlags.Public |
BindingFlags.NonPublic );
}
This code would allow access to other member
variables. This indexer, along with GetPropertyInfo,
GetFieldInfo and others could go in a superclass called
ObjectTester, that ControlTester could inherit from.
Logged In: YES
user_id=1636255
Originator: NO
I'll look into this.
There's a ComponentTester that has duplicate code with ControlTester, and it probably makes sense to pull these out into a common (abstract?) base class.