Castle DynamicProxy2: Get the Target inside an Interceptor? -


I'm using Castle Dynamic Proxy 2 on "Attack" to retrieve fields from a dictionary Example For, the following category has been given:

  Public class DataContainer: IDataContainer {Personal dictionary & lt; String, Object & gt; _field = null; Public dictionary & lt; String, Object & gt; Data {found {return_foots} (_field = new dictionary & lt; string; object & gt; ()); }}}  

I want to use the following interface to remove the "name" value outside the field dictionary:

  Public interface IContrivedExample {string Name {get; }}  

From an interceptor, I want to get the "target" data container, and want to return the "name" value:

  public zero Blocking (IInvocation invitation) {Object field name = left; // Receive the name of the field based on Inventory Information DataContainer Container = ???; // This is what I am trying to find out the invention. Return = container. Field [field name]; } // elsewhere code var c = new data container (); C.Fields.Add ("name", "Jordan"); Var pg = new proxy generator (); IContrivedExample Ice = (IContrivedExample) pg.CreateInterfaceProxyWithTarget (..., c, ...); Debug Asset (ice.Name == "Jordan");  

Any ideas about achieving the underlying goal

Note: This is a responsive example, which I use to establish some context around my question Have done

I thought it. You must enter protocol to IPOXitize:

  Public Num Lock (IInvocation invocation) {Object field name = left; // Receive field names based on invention information var accessor = invocation.Proxy as IProxyTargetAccessor; DataCentainer Container = (Datacentenair) Accessor. DynaProxyGetTagrid (); Invitation Return value = container. Field [field name]; }  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -