C# Class Castle.DynamicProxy.ModuleScope

Summary description for ModuleScope.
Show file Open project: Jarvin-Guan/CleanAOP Class Usage Examples

Public Properties

Property Type Description
DEFAULT_ASSEMBLY_NAME String
DEFAULT_FILE_NAME String

Public Methods

Method Description
DefineType ( bool inSignedModulePreferably, string name, TypeAttributes flags ) : TypeBuilder
GetFromCache ( Castle.DynamicProxy.Generators.CacheKey key ) : Type

Returns a type from this scope's type cache, or null if the key cannot be found.

GetKeyPair ( ) : byte[]

Gets the key pair used to sign the strong-named assembly generated by this ModuleScope.

LoadAssemblyIntoCache ( Assembly assembly ) : void

Loads the generated types from the given assembly into this ModuleScope's cache.

This method can be used to load previously generated and persisted proxy types from disk into this scope's type cache, eg. in order to avoid the performance hit associated with proxy generation.

ModuleScope ( ) : System

Initializes a new instance of the ModuleScope class; assemblies created by this instance will not be saved.

ModuleScope ( bool savePhysicalAssembly ) : System

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved.

ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule ) : System

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved.

ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule, INamingScope namingScope, string strongAssemblyName, string strongModulePath, string weakAssemblyName, string weakModulePath ) : System

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved and what simple names are to be assigned to them.

ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule, string strongAssemblyName, string strongModulePath, string weakAssemblyName, string weakModulePath ) : System

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved and what simple names are to be assigned to them.

ObtainDynamicModule ( bool isStrongNamed ) : ModuleBuilder

Gets the specified module generated by this scope, creating a new one if none has yet been generated.

ObtainDynamicModuleWithStrongName ( ) : ModuleBuilder

Gets the strong-named module generated by this scope, creating a new one if none has yet been generated.

ObtainDynamicModuleWithWeakName ( ) : ModuleBuilder

Gets the weak-named module generated by this scope, creating a new one if none has yet been generated.

RegisterInCache ( Castle.DynamicProxy.Generators.CacheKey key, Type type ) : void

Registers a type in this scope's type cache.

SaveAssembly ( ) : string

Saves the generated assembly with the name and directory information given when this ModuleScope instance was created (or with the DEFAULT_FILE_NAME and current directory if none was given).

This method stores the generated assembly in the directory passed as part of the module information specified when this instance was constructed (if any, else the current directory is used). If both a strong-named and a weak-named assembly have been generated, it will throw an exception; in this case, use the SaveAssembly (bool) overload.

If this ModuleScope was created without indicating that the assembly should be saved, this method does nothing.

SaveAssembly ( bool strongNamed ) : string

Saves the specified generated assembly with the name and directory information given when this instance was created (or with the DEFAULT_FILE_NAME and current directory if none was given).

This method stores the specified generated assembly in the directory passed as part of the module information specified when this instance was constructed (if any, else the current directory is used).

If this ModuleScope was created without indicating that the assembly should be saved, this method does nothing.

Private Methods

Method Description
AddCacheMappings ( AssemblyBuilder builder ) : void
CreateModule ( bool signStrongName ) : ModuleBuilder
GetAssemblyName ( bool signStrongName ) : AssemblyName

Method Details

DefineType() public method

public DefineType ( bool inSignedModulePreferably, string name, TypeAttributes flags ) : TypeBuilder
inSignedModulePreferably bool
name string
flags TypeAttributes
return System.Reflection.Emit.TypeBuilder

GetFromCache() public method

Returns a type from this scope's type cache, or null if the key cannot be found.
public GetFromCache ( Castle.DynamicProxy.Generators.CacheKey key ) : Type
key Castle.DynamicProxy.Generators.CacheKey The key to be looked up in the cache.
return System.Type

GetKeyPair() public static method

Gets the key pair used to sign the strong-named assembly generated by this ModuleScope.
public static GetKeyPair ( ) : byte[]
return byte[]

LoadAssemblyIntoCache() public method

Loads the generated types from the given assembly into this ModuleScope's cache.
This method can be used to load previously generated and persisted proxy types from disk into this scope's type cache, eg. in order to avoid the performance hit associated with proxy generation.
public LoadAssemblyIntoCache ( Assembly assembly ) : void
assembly System.Reflection.Assembly The assembly to load types from. This assembly must have been saved via or /// , or it must have the manually applied.
return void

ModuleScope() public method

Initializes a new instance of the ModuleScope class; assemblies created by this instance will not be saved.
public ModuleScope ( ) : System
return System

ModuleScope() public method

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved.
public ModuleScope ( bool savePhysicalAssembly ) : System
savePhysicalAssembly bool If set to true saves the generated module.
return System

ModuleScope() public method

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved.
public ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule ) : System
savePhysicalAssembly bool If set to true saves the generated module.
disableSignedModule bool If set to true disables ability to generate signed module. This should be used in cases where ran under constrained permissions.
return System

ModuleScope() public method

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved and what simple names are to be assigned to them.
public ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule, INamingScope namingScope, string strongAssemblyName, string strongModulePath, string weakAssemblyName, string weakModulePath ) : System
savePhysicalAssembly bool If set to true saves the generated module.
disableSignedModule bool If set to true disables ability to generate signed module. This should be used in cases where ran under constrained permissions.
namingScope INamingScope Naming scope used to provide unique names to generated types and their members (usually via sub-scopes).
strongAssemblyName string The simple name of the strong-named assembly generated by this .
strongModulePath string The path and file name of the manifest module of the strong-named assembly generated by this .
weakAssemblyName string The simple name of the weak-named assembly generated by this .
weakModulePath string The path and file name of the manifest module of the weak-named assembly generated by this .
return System

ModuleScope() public method

Initializes a new instance of the ModuleScope class, allowing to specify whether the assemblies generated by this instance should be saved and what simple names are to be assigned to them.
public ModuleScope ( bool savePhysicalAssembly, bool disableSignedModule, string strongAssemblyName, string strongModulePath, string weakAssemblyName, string weakModulePath ) : System
savePhysicalAssembly bool If set to true saves the generated module.
disableSignedModule bool If set to true disables ability to generate signed module. This should be used in cases where ran under constrained permissions.
strongAssemblyName string The simple name of the strong-named assembly generated by this .
strongModulePath string The path and file name of the manifest module of the strong-named assembly generated by this .
weakAssemblyName string The simple name of the weak-named assembly generated by this .
weakModulePath string The path and file name of the manifest module of the weak-named assembly generated by this .
return System

ObtainDynamicModule() public method

Gets the specified module generated by this scope, creating a new one if none has yet been generated.
public ObtainDynamicModule ( bool isStrongNamed ) : ModuleBuilder
isStrongNamed bool If set to true, a strong-named module is returned; otherwise, a weak-named module is returned.
return System.Reflection.Emit.ModuleBuilder

ObtainDynamicModuleWithStrongName() public method

Gets the strong-named module generated by this scope, creating a new one if none has yet been generated.
public ObtainDynamicModuleWithStrongName ( ) : ModuleBuilder
return System.Reflection.Emit.ModuleBuilder

ObtainDynamicModuleWithWeakName() public method

Gets the weak-named module generated by this scope, creating a new one if none has yet been generated.
public ObtainDynamicModuleWithWeakName ( ) : ModuleBuilder
return System.Reflection.Emit.ModuleBuilder

RegisterInCache() public method

Registers a type in this scope's type cache.
public RegisterInCache ( Castle.DynamicProxy.Generators.CacheKey key, Type type ) : void
key Castle.DynamicProxy.Generators.CacheKey The key to be associated with the type.
type System.Type The type to be stored in the cache.
return void

SaveAssembly() public method

Saves the generated assembly with the name and directory information given when this ModuleScope instance was created (or with the DEFAULT_FILE_NAME and current directory if none was given).

This method stores the generated assembly in the directory passed as part of the module information specified when this instance was constructed (if any, else the current directory is used). If both a strong-named and a weak-named assembly have been generated, it will throw an exception; in this case, use the SaveAssembly (bool) overload.

If this ModuleScope was created without indicating that the assembly should be saved, this method does nothing.

Both a strong-named and a weak-named assembly have been generated.
public SaveAssembly ( ) : string
return string

SaveAssembly() public method

Saves the specified generated assembly with the name and directory information given when this instance was created (or with the DEFAULT_FILE_NAME and current directory if none was given).

This method stores the specified generated assembly in the directory passed as part of the module information specified when this instance was constructed (if any, else the current directory is used).

If this ModuleScope was created without indicating that the assembly should be saved, this method does nothing.

No assembly has been generated that matches the parameter. ///
public SaveAssembly ( bool strongNamed ) : string
strongNamed bool True if the generated assembly with a strong name should be saved (see ); /// false if the generated assembly without a strong name should be saved (see .
return string

Property Details

DEFAULT_ASSEMBLY_NAME public static property

The default assembly (simple) name used for the assemblies generated by a ModuleScope instance.
public static String DEFAULT_ASSEMBLY_NAME
return String

DEFAULT_FILE_NAME public static property

The default file name used when the assembly is saved using DEFAULT_FILE_NAME.
public static String DEFAULT_FILE_NAME
return String