Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Problem with Reflection...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christopher Van Kirk - 18 Mar 2008 06:14 GMT
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
   }

Signature

Posted via a free Usenet account from http://www.teranews.com

Christopher Van Kirk - 18 Mar 2008 06:46 GMT
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.

> Hi all,
>    I'm having some trouble reflecting the attached class.
[quoted text clipped - 117 lines]
>        #endregion
>    }

Signature

Posted via a free Usenet account from http://www.teranews.com


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.