DynamicMetaObject + IDynamicMetaObjectProvider?

Aug 6, 2013 at 1:20 AM
Edited Aug 6, 2013 at 1:22 AM
Is there any issues inheriting from 'DynamicMetaObject' and implementing 'IDynamicMetaObjectProvider' for the same class to prevent having to create additional objects to clutter the GC? My only concern is if the additional/separate meta object is normally used in some sort of caching system.
Aug 14, 2013 at 8:11 PM
Answer: Turns out - yes, there can be an issue. The object reference that is the target of the parameter expression has to be passed into the custom "DynamicMetaObject" object that is returned from "GetMetaObject()", otherwise a cyclical call loop occurs (dead lock). It seems the meta object returned from "GetMetaObject()" is specific to the 'parameter' expression, and is cached as such for reuse (in testing, my binder is not called more than once), so it makes sense to create this new meta object specific for this purpose. Implementing both in the same object would work if the DynamicMetaObject provided a way to set "value" to "this" (the current instance) in the constructor. Right now the target value for the expression can only be passed as a parameter to the base constructor of a custom "DynamicMetaObject" object. This forces the need to create a new object, and prevents being able to reuse "this" (the current instance) as a 'DynamicMetaObject'. this is probably a good idea anyhow, as the cache system would probably keep the target object value alive. ;)