|
-
Aug 1st, 2011, 02:10 PM
#1
Thread Starter
Frenzied Member
question about System.Reflection
I have a COM object (which I did not create), and when I use the method Type.GetProperties(), it returns an array of PropertyInfo, but the thing is, it is returning a bunch of properties that don't usually show up through intellisense when accessing the properties directly (ie. comObject->property1). Is there a way to make it so that the only PropertyInfo that is returned are the ones that I see in when using intellisense? I've tried doing this:
Code:
Type.GetProperties(BindingFlags.Public)
But it ends up returning 0 properties. Any ideas? Thanks.
-
Aug 1st, 2011, 08:40 PM
#2
Re: question about System.Reflection
You should play around with various combinations of BindingFlags values. You can combine them with a bitwise Or.
-
Aug 2nd, 2011, 12:10 PM
#3
Re: question about System.Reflection
You'll need to determine whether you want instance methods include and/or static methods included. Since you've specific neither, you won't be getting any results. So, like John mentioned, you'll have to take a look at the BindingFlags that you want. It is quite likely that you'll want the Instance flag combined with your Public flag. Your flags would look like this:
Code:
BindingFlags flags = BindingFlags.Public |
BindingFlags.Instance;
// = 0001 0100
// = 20
The Type.GetProperties method you used will return all public instance or static methods.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|