C# Class Spring.Proxy.CompositionProxyTypeBuilder

Builds a proxy type using composition.
In order for this builder to work, the target must implement one or more interfaces.
Inheritance: Spring.Proxy.AbstractProxyTypeBuilder
Show file Open project: spring-projects/spring-net Class Usage Examples

Protected Properties

Property Type Description
targetInstance System.Reflection.Emit.FieldBuilder

Public Methods

Method Description
BuildProxyType ( ) : Type

Creates a proxy that delegates calls to an instance of the target object.

Only interfaces can be proxied using composition, so the target must implement one or more interfaces.

CompositionProxyTypeBuilder ( ) : System

Creates a new instance of the CompositionProxyTypeBuilder class.

PushTarget ( ILGenerator il ) : void

Generates the IL instructions that pushes the target instance on which calls should be delegated to.

Protected Methods

Method Description
CreateTargetProxyMethodBuilder ( TypeBuilder typeBuilder ) : IProxyMethodBuilder

Create an IProxyMethodBuilder to create interface implementations

DeclareTargetInstanceField ( TypeBuilder builder ) : void

Deaclares a field that holds the target object instance.

GenerateConstructor ( ConstructorBuilder builder, ILGenerator il, ConstructorInfo constructor ) : void

Generates the proxy constructor.

This implementation creates instance of the target object for delegation using constructor arguments.

ImplementCustom ( TypeBuilder builder ) : void

Allows subclasses to generate additional code

Method Details

BuildProxyType() public method

Creates a proxy that delegates calls to an instance of the target object.

Only interfaces can be proxied using composition, so the target must implement one or more interfaces.

/// If the /// does not implement any interfaces. ///
public BuildProxyType ( ) : Type
return System.Type

CompositionProxyTypeBuilder() public method

Creates a new instance of the CompositionProxyTypeBuilder class.
public CompositionProxyTypeBuilder ( ) : System
return System

CreateTargetProxyMethodBuilder() protected method

Create an IProxyMethodBuilder to create interface implementations
protected CreateTargetProxyMethodBuilder ( TypeBuilder typeBuilder ) : IProxyMethodBuilder
typeBuilder System.Reflection.Emit.TypeBuilder
return IProxyMethodBuilder

DeclareTargetInstanceField() protected method

Deaclares a field that holds the target object instance.
protected DeclareTargetInstanceField ( TypeBuilder builder ) : void
builder System.Reflection.Emit.TypeBuilder /// The builder to use for code generation. ///
return void

GenerateConstructor() protected method

Generates the proxy constructor.

This implementation creates instance of the target object for delegation using constructor arguments.

protected GenerateConstructor ( ConstructorBuilder builder, ILGenerator il, ConstructorInfo constructor ) : void
builder System.Reflection.Emit.ConstructorBuilder The constructor builder to use.
il System.Reflection.Emit.ILGenerator The IL generator to use.
constructor System.Reflection.ConstructorInfo The constructor to delegate the creation to.
return void

ImplementCustom() protected method

Allows subclasses to generate additional code
protected ImplementCustom ( TypeBuilder builder ) : void
builder System.Reflection.Emit.TypeBuilder
return void

PushTarget() public method

Generates the IL instructions that pushes the target instance on which calls should be delegated to.
public PushTarget ( ILGenerator il ) : void
il System.Reflection.Emit.ILGenerator The IL generator to use.
return void

Property Details

targetInstance protected property

Target instance calls should be delegated to.
protected FieldBuilder,System.Reflection.Emit targetInstance
return System.Reflection.Emit.FieldBuilder