Is there a way to determine the access modifiers of a class type in an
assembly via reflection? I see that I can determine if the class is public
or non-public, but I would like to be able to further sub-divide the
non-public modifiers (assembly, family, familyAndAssembly, familyOrAssembly,
private). Is this possible with the .NET 1.1 Reflection API? And just to
clarify, I see I can get this info for nested classes, but I would like it
for non-nested classes too.
Thanks for any suggestions or pointers on this.
Kevin
AlexS - 21 May 2004 18:46 GMT
Hi, Kevin
check Type.Attributes property and related TypeAttributes Enumeration -
they should provide you with required information
HTH
Alex
> Is there a way to determine the access modifiers of a class type in an
> assembly via reflection? I see that I can determine if the class is public
[quoted text clipped - 7 lines]
>
> Kevin
Kevin Lindsey - 21 May 2004 19:10 GMT
Hi Alex,
> check Type.Attributes property and related TypeAttributes Enumeration -
> they should provide you with required information
Yeah, that's what I'm using currently, but it does not provide the break
down for non-public classes. Surprisingly to me, it does provide this
information for nested classes, but not the non-nested ones.
Thanks though.
Kevin
Jon Skeet [C# MVP] - 21 May 2004 19:08 GMT
> Is there a way to determine the access modifiers of a class type in an
> assembly via reflection? I see that I can determine if the class is public
[quoted text clipped - 3 lines]
> clarify, I see I can get this info for nested classes, but I would like it
> for non-nested classes too.
Unless the class is nested, it can only be public or internal - it
doesn't make sense for a non-nested type to be protected (family), for
instance.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Mattias Sj?gren - 21 May 2004 19:11 GMT
Kevin,
>I see that I can determine if the class is public
>or non-public, but I would like to be able to further sub-divide the
>non-public modifiers (assembly, family, familyAndAssembly, familyOrAssembly,
>private). Is this possible with the .NET 1.1 Reflection API? And just to
>clarify, I see I can get this info for nested classes, but I would like it
>for non-nested classes too.
For non-nested classes only public and non-public (which you can think
of as private or assembly, there's no difference at the top level)
makes sense. family isn't applicable since there's nothing one level
up that you can inherit from.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Kevin Lindsey - 21 May 2004 19:32 GMT
I now see what was wrong in my thinking, but it looks like I need to do a
little reading to understand why that is wrong.
Thanks guys!
Kevin