ApplicationContext

Interface for the application context.

Namespace:
Inetdev.Context
Type:
Class
Public:
Yes
Protected:
No
Sealed:
No
Abstract:
No
Inherits from:
System.Object
Implements:
System.IDisposable

Constructors

ApplicationContext

Default constructor

Signature:
public Void ApplicationContext()

Properties

Configuration

Provides access to configuration.

Signature:
public IConfiguration Configuration { get; set; }

Current

The application context.

Signature:
public ApplicationContext Current { get; set; }

Factories

Collection of factories contained in this application context.

Signature:
public ICollection<IObjectFactory> Factories { get; }

Items

A dictionary that holds objects of any kind.

Signature:
public IDictionary<String, Object> Items { get; }

Packages

Collection of packages contained in this application context.

Signature:
public ICollection<IPackage> Packages { get; }

Methods

ContainsFactory

Finds out if the application context contains a factory of the given name.

Signature:
public Boolean ContainsFactory(name)
Returns

true if the object factory exists or false otherwise.

Parameters
Name Type Summary
name String The name of the object factory to verify.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when the name is null or empty.

ContainsObject

Finds out if the application context contains an object of the given name.

Signature:
public Boolean ContainsObject(name)
Returns

true if the application context contains the object or false if not.

Parameters
Name Type Summary
name String The name of the object to verify.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when the name is null or empty.

ContainsObject

Finds out if the application context contains an object of the given Type.

Signature:
public Boolean ContainsObject(objectType)
Returns

true if the application context contains the object or false if not.

Parameters
Name Type Summary
objectType Type The Type of the object to verify.
Exceptions
Type Summary
ArgumentNullException Thrown when objectType is null.

ContainsPackage

Find out if the application context contains a package of the given name.

Signature:
public Boolean ContainsPackage(name)
Returns

true if the application context contains the software package or false if not.

Parameters
Name Type Summary
name String The name of the package to verify.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when the name is null or empty.

Dispose

Performs application specific clean up.

Signature:
public Void Dispose()

GetFactory

Retrieves the object factory of the given name.

Signature:
public IObjectFactory GetFactory(name)
Returns

The IObjectFactory of the given name.

Parameters
Name Type Summary
name String The name of the object factory to retrive.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when the name is null or empty.
NoSuchFactoryException Thown when the specify object factory does not exists.

GetObject

Retrieves an initialized instance of the object for the given type .

Signature:
public GetObject<T>()

GetObject

Retrieves an initialized instance of the object for the given type .

Signature:
public GetObject<T>(args)
Parameters
Name Type Summary
args Object[] Constructor arguments.
Exceptions
Type Summary
NoSuchObjectException Thrown when the Factory does not contains the required object.

GetObject

Retrieves an initialized instance of the object of the given name.

Signature:
public Object GetObject(name)
Returns

The object of the given name.

Parameters
Name Type Summary
name String The name of the object to retrieve.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.

GetObject

Retrieves an initialized instance of the object of the given name throwing an exception only id specified.

Signature:
public Object GetObject(name, thrown)
Returns

The object of the given name.

Parameters
Name Type Summary
name String The name of the object to retrieve.
thrown Boolean true if an exception should be thrown or false if null should be returned.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.

GetObject

Retrieves an initialized instance of the object for the given name, passing the arguments to the object constructor.

Signature:
public Object GetObject(name, args)
Returns

The context object.

Parameters
Name Type Summary
name String The name of the object to retrive.
args Object[] The arguments to pass to the constructor.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.

GetObject

Retrives an initialized instance of the object of the given name only if it is of the given Type.

Signature:
public Object GetObject(name, requiredType)
Returns

The object of the given name.

Parameters
Name Type Summary
name String The name of the object to retrive.
requiredType Type The required Type of the object.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.
ObjectNotOfRequiredTypeException Thrown the the object is not of the required type.

GetObject

Retrieves an initialized instance of the first object of objectType type.

Signature:
public Object GetObject(objectType)
Parameters
Name Type Summary
objectType Type The exact type of the object to retrive.
Exceptions
Type Summary
ArgumentNullException Thrown when objectType is null.
NoSuchObjectException Thrown when there is no objects of the required object.

GetObject

Retrieves an initialized instance of the first object of objectType type.

Signature:
public Object GetObject(objectType, args)
Parameters
Name Type Summary
objectType Type The exact type of the object to retrive.
args Object[] Constructor arguments.
Exceptions
Type Summary
ArgumentNullException Thrown when objectType is null.
NoSuchObjectException Thrown when there is no objects of the required object.

GetObjectsAssignableFrom

Get a list of objects that are assignable from type .

Signature:
public IEnumerable GetObjectsAssignableFrom<T>()
Returns

A list of objects assignable from type .

GetObjectsAssignableFrom

Get a list of objects that are assignable from type.

Signature:
public IEnumerable<Object> GetObjectsAssignableFrom(type)
Returns

A list of objects assignable from type type.

Parameters
Name Type Summary
type Type The type that the objects are assignable from.
Exceptions
Type Summary
ArgumentNullException Thrown when type is null.

GetObjectsOfContextAssignableFrom

Retrieves a list of initialized context object that are assignable from type type.

Signature:
public IEnumerable<Object> GetObjectsOfContextAssignableFrom(type)
Returns

A list of objects assignable from type.

Parameters
Name Type Summary
type Type The type that the objects are asignable from.
Exceptions
Type Summary
ArgumentNullException Thrown when type is null.

GetObjectsOfContextAssignableFrom

Retrieves a list of initialized context object that are assignable from type .

Signature:
public IEnumerable GetObjectsOfContextAssignableFrom<T>()
Returns

A list of objects assignable from type .

GetPackage

Retrieves the software package of the given name.

Signature:
public IPackage GetPackage(name)
Returns

The software package of the given name.

Parameters
Name Type Summary
name String The name of the package to retrives.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchPackageException Thown the the required package does not exists.

GetType

Retrives the Type of the object of the given name.

Signature:
public Type GetType(name)
Returns

The Type of the context object.

Parameters
Name Type Summary
name String The name of the object to retrive it's type.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.

InjectDependencies

Inject into the object o the dependencies of an object named name.

Signature:
public Void InjectDependencies(name, o)
Parameters
Name Type Summary
name String The name of the object to get it's dependencies.
o Object The object where to inject the dependencies.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
ArgumentNullException Thrown when o is null.
NoSuchObjectException Thrown when there is not object of the given name.

IsSingleton

Finds out if the object of the given name is a singleton.

Signature:
public Boolean IsSingleton(name)
Returns

true if the object is a singleton or false if not.

Parameters
Name Type Summary
name String The name of the object to verify.
Exceptions
Type Summary
ArgumentNullOrEmptyException Thrown when name is null or empty.
NoSuchObjectException Thrown when there is not object of the given name.

RegisterFactory

Adds the specified IObjectFactory to the factory list.

Signature:
public Void RegisterFactory(factory)
Parameters
Name Type Summary
factory IObjectFactory The factory to add to the application context.
Exceptions
Type Summary
ArgumentNullException Thown when factory is null.
ContextConfigurationException Thown when a factory with the same name already exists.

RegisterPackage

Adds the specified software package to the packages list.

Signature:
public Void RegisterPackage(package)
Parameters
Name Type Summary
package IPackage The package to add to the application context.
Exceptions
Type Summary
ArgumentNullException Thown when the argument package is null.
ContextConfigurationException Thrown when package configuration is invalid.

ToString

Returns a textual representation of the object.

Signature:
public String ToString()