DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Jon Stonecash Guest

    Reflection: Type Methods and Properties

    If I define a type and then declare an instance of that type in my code,
    Intellisence will show me the methods, properties, fields, etc. defined by by
    type. If I get the Type instance for my type and use GetProperties, I get the
    properties that I expect. If, on the other hand, I use GetMethods, I get a
    numer of entries that I do not expect. Specifically, I get the set_ and Get_
    methods for the properties. Clearly Intellisence can figure out that these
    extra methods are not to be displayed. What I cannot figure out is how to
    determine that the set_MyProperty method is actually a part of a property.

    Can anyone out there point me in the right direction?

    Jon Stonecash
    Rainier Technology, Inc.


  2. #2
    Mattias Sjögren Guest

    Re: Reflection: Type Methods and Properties

    Jon,

    >Can anyone out there point me in the right direction?


    Take a look at the GetMethods overload that takes a BindingFlags
    parameter. I haven't tried it myself, but I believe you can use it to
    specify which methods to include.


    Matt

    ====================================
    Mattias Sjögren - mattias @ mvps.org
    http://www.msjogren.net/dotnet/

    CodeHound - The Software Developer's Search Engine
    http://www.codehound.com

  3. #3
    Jon Stonecash Guest

    Re: Reflection: Type Methods and Properties

    On Wed, 14 Feb 2001 17:00:45 GMT, mattias.dont.want.spam@mvps.org (Mattias
    Sjögren) wrote:

    >Jon,
    >
    >>Can anyone out there point me in the right direction?

    >
    >Take a look at the GetMethods overload that takes a BindingFlags
    >parameter. I haven't tried it myself, but I believe you can use it to
    >specify which methods to include.
    >
    >
    >Matt
    >
    >====================================
    >Mattias Sjögren - mattias @ mvps.org
    >http://www.msjogren.net/dotnet/
    >
    >CodeHound - The Software Developer's Search Engine
    >http://www.codehound.com


    Interesting suggestion, but no cigar. While there are a whole bunch of binding
    flags, the documentation and my non-exhaustive testing suggest that only the
    Public, Nonpublic, Instance, Static, and DeclaredOnly flags have any effect on
    the GetMethods and GetMembers methods. Unfortunately, the effects are not the
    ones that I want. I learned some more about dotnet but not what I wanted.

    Thnaks for the effort.

    Jon Stonecash
    Rainier Technology, Inc.


  4. #4
    Bill McCarthy Guest

    Re: Reflection: Type Methods and Properties

    Hi Jon,

    Try getting all the methods, and store them in a list or hashtable etc. Next
    get all the properties. For each property call on the getGetter and
    GetSetter and do a test against each member in you first list (or do a
    Contains lookup).


    "Jon Stonecash" <jon.stonecash@rainier.com> wrote in message
    news:rmpl8tkbq46uuk4o5ve9url0g054nvcrl1@4ax.com...
    > On Wed, 14 Feb 2001 17:00:45 GMT, mattias.dont.want.spam@mvps.org (Mattias
    > Sjögren) wrote:
    >
    > >Jon,
    > >
    > >>Can anyone out there point me in the right direction?

    > >
    > >Take a look at the GetMethods overload that takes a BindingFlags
    > >parameter. I haven't tried it myself, but I believe you can use it to
    > >specify which methods to include.
    > >
    > >
    > >Matt
    > >
    > >====================================
    > >Mattias Sjögren - mattias @ mvps.org
    > >http://www.msjogren.net/dotnet/
    > >
    > >CodeHound - The Software Developer's Search Engine
    > >http://www.codehound.com

    >
    > Interesting suggestion, but no cigar. While there are a whole bunch of

    binding
    > flags, the documentation and my non-exhaustive testing suggest that only

    the
    > Public, Nonpublic, Instance, Static, and DeclaredOnly flags have any

    effect on
    > the GetMethods and GetMembers methods. Unfortunately, the effects are not

    the
    > ones that I want. I learned some more about dotnet but not what I wanted.
    >
    > Thnaks for the effort.
    >
    > Jon Stonecash
    > Rainier Technology, Inc.
    >




  5. #5
    Jon Stonecash Guest

    Re: Reflection: Type Methods and Properties

    Bill,

    What you suggested works. I must say that it seems awkward to do it that way.
    It means that I have to build a list of methods, pass each get and set method
    against the list, and substract out the stuff that I do not want. I have to do
    this for both properties and events. I keep thinking that there must be a
    shorter way to get from here to there.

    Thanks for the help.

    Jon Stonecash


    On Thu, 15 Feb 2001 12:31:49 +1100, "Bill McCarthy" <Bill_McC@iprimus.com.au>
    wrote:

    >Hi Jon,
    >
    >Try getting all the methods, and store them in a list or hashtable etc. Next
    >get all the properties. For each property call on the getGetter and
    >GetSetter and do a test against each member in you first list (or do a
    >Contains lookup).
    >
    >
    >"Jon Stonecash" <jon.stonecash@rainier.com> wrote in message
    >news:rmpl8tkbq46uuk4o5ve9url0g054nvcrl1@4ax.com...
    >> On Wed, 14 Feb 2001 17:00:45 GMT, mattias.dont.want.spam@mvps.org (Mattias
    >> Sjögren) wrote:
    >>
    >> >Jon,
    >> >
    >> >>Can anyone out there point me in the right direction?
    >> >
    >> >Take a look at the GetMethods overload that takes a BindingFlags
    >> >parameter. I haven't tried it myself, but I believe you can use it to
    >> >specify which methods to include.
    >> >
    >> >
    >> >Matt
    >> >
    >> >====================================
    >> >Mattias Sjögren - mattias @ mvps.org
    >> >http://www.msjogren.net/dotnet/
    >> >
    >> >CodeHound - The Software Developer's Search Engine
    >> >http://www.codehound.com

    >>
    >> Interesting suggestion, but no cigar. While there are a whole bunch of

    >binding
    >> flags, the documentation and my non-exhaustive testing suggest that only

    >the
    >> Public, Nonpublic, Instance, Static, and DeclaredOnly flags have any

    >effect on
    >> the GetMethods and GetMembers methods. Unfortunately, the effects are not

    >the
    >> ones that I want. I learned some more about dotnet but not what I wanted.
    >>
    >> Thnaks for the effort.
    >>
    >> Jon Stonecash
    >> Rainier Technology, Inc.
    >>

    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links