IronPython overrides __setattr__ and __getattr__

I am trying to implement a class in C # using a method that intercepts Python magic methods __setattr__ and __getattr__. I found this error report:

http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=8143

But this is from 2008, and I can not find ICustomAttributes or PythonNameAttribute anywhere. I do not see anything useful in Interfaces.cs. Can someone point me in the right direction?

+3
source share
1 answer

I do not use IronPython, so I may be completely wrong, but here is what I could assume.

, Dynamic Language Runtime .NET 4.0, IronPython DLR, .NET , / //. , IDynamicMetaObjectProvider. - DynamicObject, , (. DynamicObject):

class MyObject : DynamicObject {
  public override bool TryGetMember
      (GetMemberBinder binder, out object result) {
    string name = binder.Name;
    // set the 'result' parameter to the result of the call
    return // true to pretend that attribute called 'name' exists
  }

  public override bool TrySetMember
      (SetMemberBinder binder, object value) {
    // similar to 'TryGetMember'
  }  
}

# dynamic. IronPython !

+4

Source: https://habr.com/ru/post/1739543/


All Articles