C# Class Command.Context

Records the current context within which Commands are executed. A Context is like a session object; it holds the current set of live object instances on which commands will be invoked. The Context is also able to use the Factory registration information to create new object instances as required, provided they can be created from objects currently in the context.
Show file Open project: agardiner/hfmcmd

Public Properties

Property Type Description
MissingArgHandler object>.Func

Protected Properties

Property Type Description
_context List
_dependencyList List>.Dictionary
_log log4net.ILog
_purgeList List
_registry Registry

Public Methods

Method Description
Context ( Registry registry ) : System
Context ( Registry registry, object>.Func missingArgHandler ) : System
FindPathToType ( Type t, Command cmd ) : Stack

Determines the sequence of command invocations, property accesses, and constructor calls that are required to instantiate an object of the requested type, given the current state of the context.

GetSettings ( Type type ) : List

Returns the SettingAttributes for the specified type.

HasObject ( Type type ) : bool

Returns true if the Context currently contains an instance of the requested type.

Invoke ( string command, object>.Dictionary args ) : object

Invoke an instance of the named command, using the supplied arguments dictionary to obtain parameter values. If necessary, this will execute Factory constructors, properties, and commands to obtain the necessary source object on which to invoke the command.

Remove ( Type type ) : object

Removes the first object that is an instance of type.

Set ( object value ) : void

Sets an object in the context. Only a single object of a given type is permitted, so any existing object of this type is replaced.

Set ( object value, object dependency ) : void

Sets an object in the context. Only a single object of a given type is permitted, so any existing object of this type is replaced.

Verify ( ) : void

Verifies that all commands can be invoked successfully.

this ( Type type ) : object

Protected Methods

Method Description
RemoveDependencies ( object val ) : void

Private Methods

Method Description
ConvertSetting ( object val, ISetting setting ) : object
Instantiate ( Factory step, object>.Dictionary args ) : object
InvokeCommand ( Command cmd, object>.Dictionary args ) : object
InvokeConstructor ( ConstructorInfo ctor ) : object
LogSettingNameValue ( StringBuilder sb, string name, ISetting setting, object val ) : void
LogSettingValue ( StringBuilder sb, ISetting setting, object val ) : void
PrepareCommandArguments ( Command cmd, object>.Dictionary args, string &paramLog ) : object[]
PrepareSettingsCollectionArg ( Command cmd, CommandParameter param, object>.Dictionary args, StringBuilder sb ) : ISettingsCollection
PurgeSingleUseObjects ( ) : void

Method Details

Context() public method

public Context ( Registry registry ) : System
registry Registry
return System

Context() public method

public Context ( Registry registry, object>.Func missingArgHandler ) : System
registry Registry
missingArgHandler object>.Func
return System

FindPathToType() public method

Determines the sequence of command invocations, property accesses, and constructor calls that are required to instantiate an object of the requested type, given the current state of the context.
Throws ContextException if an object of the desired type /// cannot be created from the current context. ///
public FindPathToType ( Type t, Command cmd ) : Stack
t System.Type
cmd Command
return Stack

GetSettings() public method

Returns the SettingAttributes for the specified type.
public GetSettings ( Type type ) : List
type System.Type
return List

HasObject() public method

Returns true if the Context currently contains an instance of the requested type.
public HasObject ( Type type ) : bool
type System.Type
return bool

Invoke() public method

Invoke an instance of the named command, using the supplied arguments dictionary to obtain parameter values. If necessary, this will execute Factory constructors, properties, and commands to obtain the necessary source object on which to invoke the command.
public Invoke ( string command, object>.Dictionary args ) : object
command string
args object>.Dictionary
return object

Remove() public method

Removes the first object that is an instance of type.
public Remove ( Type type ) : object
type System.Type
return object

RemoveDependencies() protected method

protected RemoveDependencies ( object val ) : void
val object
return void

Set() public method

Sets an object in the context. Only a single object of a given type is permitted, so any existing object of this type is replaced.
public Set ( object value ) : void
value object
return void

Set() public method

Sets an object in the context. Only a single object of a given type is permitted, so any existing object of this type is replaced.
public Set ( object value, object dependency ) : void
value object
dependency object
return void

Verify() public method

Verifies that all commands can be invoked successfully.
public Verify ( ) : void
return void

this() public method

public this ( Type type ) : object
type System.Type
return object

Property Details

MissingArgHandler public property

public Func MissingArgHandler
return object>.Func

_context protected property

protected List _context
return List

_dependencyList protected property

protected Dictionary> _dependencyList
return List>.Dictionary

_log protected static property

protected static ILog,log4net _log
return log4net.ILog

_purgeList protected property

protected List _purgeList
return List

_registry protected property

protected Registry,Command _registry
return Registry