.NET Framework Bookmark and Share   
 index > .NET Base Class Library > Disabling Property's Set Method Temporarily
 

Disabling Property's Set Method Temporarily

Hi
I am using System.Reflections to analyze all the properties of an object (any class) through boxing method. Using PropertyInfo class, I am changing the values of the properties also.

Is there any method in System.Reflections, through which the set accessors of a given property could be disabled temporarily so that the value changes in that property from elsewhere could be denied through code.

I want to implement a lock feature in my code using System.Reflections so that, during application of lock, nobody could change the property value.

Ravish_Tipu
That's not possible. If you want the setter to be disabled, you'll have to put the disabling logic in the setter function itself.
Hans Passant.
nobugz
Evenif therewere such functionality in the reflection namespace it would seem to be an odd way of achieving whatyou want to do. Why do you want to use reflection for this? Perhaps if you explained the "bigger picture" a little bit more in detail, like who or whatwants to lock the objects and for what reason.
Like Hans stated in his post you could put some IF-statement in the setter function but that might not be the best overall design approach.

/Calle
Calle Mellergardh
That's not possible. If you want the setter to be disabled, you'll have to put the disabling logic in the setter function itself.
Hans Passant.
nobugz
Evenif therewere such functionality in the reflection namespace it would seem to be an odd way of achieving whatyou want to do. Why do you want to use reflection for this? Perhaps if you explained the "bigger picture" a little bit more in detail, like who or whatwants to lock the objects and for what reason.
Like Hans stated in his post you could put some IF-statement in the setter function but that might not be the best overall design approach.

/Calle
Calle Mellergardh

You can use google to search for other answers

Custom Search

More Threads

• Problem in device manager class
• 100 microseconds timer
• Find Method for collections
• Can I create a function which calculates the wall time of other functions?
• How Can we preserve strong naming for Enterprise Library assemblies after Compilation ?
• How to get the DomainSid or domain Sid ?
• C# Serial Port string or stringbuilder
• How to append data in the begining of a file?
• Convert it into c# .net?
• How to create and delete a temporary file in ASP.NET?