Problem with Reflection...

  • Thread starter Thread starter Christopher Van Kirk
  • Start date Start date
C

Christopher Van Kirk

Hi all,
I'm having some trouble reflecting the attached class.

I have an IList<ICell<object>> collection of them. I get the first
instance of ICell<object> in the list and call GetType() on it to get the
concrete type of the implementation of ICell<object>, which is the class
below. Then when I attempt to call the .GetFields or .GetField methods on
that type with binding flags BindingFlags.Instance | BindingFlags.Public |
BindingFlags.FlattenHierarchy nothing comes back. I can, however, see the
three private fields if I call it with BindingFlags.Instance |
BindingFlags.NonPublic.

Any idea why the public methods of the class might be invisible?

Chris...

The culprit ->

/// <summary>
/// Generic implementation of ICell.
/// </summary>
public class GenericCell<VALUETYPE> : ICell<VALUETYPE>
{
IMessageLogger logger;

IList<IBaseMember> address;
IValue<VALUETYPE> value;

/// <summary>
/// Creates a cell given an address and a value.
/// </summary>
/// <param name="address">The address of the cell.</param>
/// <param name="value">The value of the cell.</param>
public GenericCell(IList<IBaseMember> address, IValue<VALUETYPE>
value)
{
this.address = address;
this.value = value;
}

/// <summary>
/// Creates a cell given an address and a value.
/// </summary>
/// <param name="address">The address of the cell.</param>
/// <param name="value">The value of the cell.</param>
public GenericCell( IList<IBaseMember> address, IBaseValue value)
{
this.address = address;
this.value = value as IValue<VALUETYPE>;
}

#region ICell<VALUETYPE> Members

/// <summary>
/// Gets the value of the cell.
/// </summary>
public VALUETYPE Value
{
get
{
return this.value.Value;
}
}

/// <summary>
/// Gets the IValue associated with this cell.
/// </summary>
public IValue<VALUETYPE> IValue
{
get
{
return this.value;
}
}

/// <summary>
/// Gets the address of the cell.
/// </summary>
public IList<IBaseMember> Address
{
get
{
return this.address;
}
}

#endregion

#region IBaseCell Members

/// <summary>
/// Gets the ambiguously typed value of the cell.
/// </summary>
object IBaseCell.Value
{
get
{
object rv = null;

if (this.value != null)
{
rv = this.value.Value;
}

return rv;
}
}

/// <summary>
/// Gets the IValue associated with this cell.
/// </summary>
IBaseValue IBaseCell.IValue
{
get
{
return this.value as IBaseValue;
}
}

#endregion
}
 
Scratch that...I figured it out myself. The reason I can't see the public
members coming back from the GetFields() method is that they're not fields,
they're members.
 
Back
Top