I have a set of properties, some of them have private
setter and some of them have internal
setter. Is there any way that at runtime I can check whether setter of a property is internal
or not?
Asked
Active
Viewed 178 times
1

Adi Lester
- 24,731
- 12
- 95
- 110

BigBoss
- 6,904
- 2
- 23
- 38
-
1@jon doesn't [this](http://msdn.microsoft.com/en-us/library/system.reflection.methodbase.isassembly.aspx) tell you what you need to know? – Blorgbeard Jun 26 '13 at 20:50
-
@Jon well wouldn't the answer disagree? – It'sNotALie. Jun 26 '13 at 20:54
-
@newStackExchangeInstance: You are right. Thanks for the refresher :) – Jon Jun 26 '13 at 21:00
1 Answers
5
You can get this info using reflection:
var myType = obj.GetType();
var setMethod = myType.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
.GetSetMethod(true);
bool isInternalSetter = setMethod != null && setMethod.IsAssembly;

Adi Lester
- 24,731
- 12
- 95
- 110