Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6813113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:31:56+00:00 2026-05-26T20:31:56+00:00

I have written an abstract class that I am using to automate a lot

  • 0

I have written an abstract class that I am using to automate a lot of INotifyPropertyChanged and IDataErrorInfo stuff. However this requires that I specify a custom getter/setter which calls a custom method for every property.

To avoid the extra typing I have been trying to find a way to override/handle the property getters/setters in an object and call the custom method instead of the generated getter/setter.

I tried inheriting from DynamicObject and overriding TryGetMember and TrySetMember, however these methods only seem to work if the object is declared as dynamic.

So I want to know if what I am trying to achieve is possible at all through .NET reflection or some other mechanism, also is there anyway to detect if the property setter/getter has been defined in code?

Thanks,
Alex.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:31:56+00:00Added an answer on May 26, 2026 at 8:31 pm

    You can get information about properties of a type using Type.GetProperties method. You will receive a collection of PropertyInfo object. Those object have CanRead and CanWrite properties which say if properties are readable/writable.

    To override this behavior you would have to:

    1. Create dynamic proxy generator
    2. Dynamic proxies should intercept calls to methods in form of get_PropA and set_PropA, which are effectively getters and setters, where you can add your additional logic
    3. Instead of using constructors in code to create those objects, use your proxy generator which will create the object and then wrap it inside a proxy.
    4. Naturally, your classes must not be sealed, and properties must be virtual in order to create proxy

    For free solutions you are best to use Castle DynamicProxy. If you are ready to spend some money, take a look at PostSharp which already implements many things of similar nature. Like INotifyProperty chage, undo/redo etc. You could also take a look at any AOP framework which supports aspect weaving, but DynamicProxy would be my pick for situation you described.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an abstract test case class that is to be extended by
I have written a class in python that implements __str__(self) but when I use
I have written a program that uses qhttp to get a webpage. This works
I've written an abstract base class for unit tests that sets up just enough
I have an interface Tree and an abstract class RBTree which implements this interface.
I have one main interface and an abstract class implementing all derivable methods (that
I have the following class written by someone else that I'm trying to understand
I have a class I've written to act like an enumeration: abstract class Enum
I've written a class that implements IEnumerable<T> . I have a method that returns
I have built an abstract class that is used to handle command line options

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.