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 6979645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:54:46+00:00 2026-05-27T17:54:46+00:00

I do a custom implementation of IDynamicMetaObjectProvider in C#, since I need better performance

  • 0

I do a custom implementation of IDynamicMetaObjectProvider in C#, since I need better performance than it is possible to achieve with DynamicObject and I need inheritance. I extend DynamicMetaObject with custom implementations of BindSetMember and BindGetMember. My question is:

When are BindSetMember and BindGetMember called and when are cached rules used? I.e., what is the cache configuration?

From debugging my implementation I understood that, e.g., BindSetMember is called for each specific IDynamicMetaObjectProvider class, property name and argument type. But I have not found any documentation of this. Furthermore, in the following code BindSetMember is called two times and BindGetMember is called two times, while I expect that each of them is called once:

dynamic obj = new MyDynamicImplementation();
obj.Property = 0; // Calls BindSetMember
if (obj.Property != 0) {} // Calls BindGetMember
obj.Property++; // Calls BindGetMember, then BindSetMember

Can anyone explain or give reference to documentation where my above questions are explained?

  • 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-27T17:54:47+00:00Added an answer on May 27, 2026 at 5:54 pm

    A simple and high-level explanation is that the cache is done per type and per call site. In the above example, call sites correspond to code lines. Thus the cache is not used for any of the lines.

    An example of using cache is accessing a property in a loop such as:

    for (int i = 0; i < 10; i++)
        obj.Property = i;
    

    In the above example binding will be done once, when i = 0, and then cache will be utilized for next 9 calls.

    More complex example of using cache:

    public class Class1 : MyDynamicImpelementation {}
    public class Class2 : MyDynamicImpelementation {}
    
    static class Class
    {
        public void PropertyAccess(dynamic obj)
        {
            for (int i = 0; i < 10; i++)
                obj.Property = i;
        }
    
        public void Main(string[] args)
        {
            PropertyAccess(new Class1());
            PropertyAccess(new Class2());
        }
    }
    

    In the above example binding will be done only once for obj of type Class1 and i = 0, then the cache will be used for the rest of the loop calls and for obj of type Class2 and any i.

    As conclusion:
    BindGetMethod and BindSetMethod are called if a property accessed from different lines of code or if the type of a value is different.

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

Sidebar

Related Questions

There is a custom implementation of KSPA which needs to be re-written. The current
My question is : how to move beyond writing a custom implementation of a
I'm considering writing a custom IPermission implementation but am not clear as to how
I was trying to create an IFormatProvider implementation that would recognize custom format strings
How can I write a custom IEnumerator<T> implementation which needs to maintain some state
For an ASP.NET application, what is the Best Practice implementation method for a custom
I have a custom implementation of IResourceProvider and ResourceProviderFactory . Now the default way
I have a FileSyncProvider and I've written a custom implementation of the FullEnumerationSimpleSyncProvider .
if I have two custom implementation of IAuthorizationFilter, and both of them applied to
For my application, I have a custom implementation of SharedPreferences . In API level

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.