Implements a generic IObjectFactory.
Default constructor
protected Void ObjectFactory()
Application context object factory name.
public String Name { get; set; }
Finds out if the factory contains an object of the given name.
public Boolean ContainsObject(name)
true if the factory contains the object.
Name | Type | Summary |
---|---|---|
name | String | Name of the object to find. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
Finds out if the factory contains an object of the given type.
public Boolean ContainsObject(objectType)
true if the factory contains the object.
Name | Type | Summary |
---|---|---|
objectType | Type | Type of the object to find. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when objectType is null. |
Creates a new instance of the application context object.
protected Object CreateInstance(cfg, args)
A newly created instance of the application context object.
Name | Type | Summary |
---|---|---|
cfg | ObjectConfiguration | Object configuration. |
args | Object[] | Arguments to pass to the constructor. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when cfg is null. |
Performs a clean up.
public Void Dispose()
Gets an initialized instance of an object for the given name.
public Object GetObject(name)
An initialized instance of the object named name.
Name | Type | Summary |
---|---|---|
name | String | The name of the object to retrieve. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
Gets an initialized instance of an object for the given name. If there isn´t an object for the given name or if there is an error getting the object, an exception is thrown only if thrown is true otherwise null is returned.
public Object GetObject(name, thrown)
An initialized instance of the object named name.
Name | Type | Summary |
---|---|---|
name | String | The name of the object to retrieve. |
thrown | Boolean | Whether to throw an exception of not. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
NoSuchObjectException | Thrown when there are no object for the given name and thrown is true. |
Gets an instance of the object for the given name.
public Object GetObject(name, args)
An initialized instance of the object named name.
Name | Type | Summary |
---|---|---|
name | String | The name of the object to retrieve. |
args | Object[] | Arguments to be passed to the constructor. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
NoSuchObjectException | Thrown when there isn't an object for the given name. |
Gets an initialized instance of a object for the given name only if the object type is equal to requiredType.
public Object GetObject(name, requiredType)
An initialized instance of the object named name.
Name | Type | Summary |
---|---|---|
name | String | The name of the object to retrieve. |
requiredType | Type | Required Type of the object. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
NoSuchObjectException | Thrown when there isn't an object for the given name. |
ObjectNotOfRequiredTypeException | Thown the the object is not of type requiredType. |
Gets an initialized instance of the object for the given objectType.
public Object GetObject(objectType)
An initialized instance of the object for the given type.
Name | Type | Summary |
---|---|---|
objectType | Type | Type of the object to retrive. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when objectType is null. |
NoSuchObjectException | Thrown when there are no object for the given type. |
Gets an initialized instance of the object for the given objectType.
public Object GetObject(objectType, args)
An initialized instance of the object for the given type.
Name | Type | Summary |
---|---|---|
objectType | Type | Type of the object to retrive. |
args | Object[] | Arguments to pass to the constructor. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when objectType is null. |
NoSuchObjectException | Thrown when there are no object for the given type. |
Gets an initialized instance of an object of type
public GetObject<T>()
An initialized object of type
Gets an initialized instance of an object of type
public GetObject<T>(args)
An initialized object of type
Name | Type | Summary |
---|---|---|
args | Object[] | Arguments to be passed to the constructor. |
Type | Summary |
---|---|
NoSuchObjectException | Thrown when there are no objects of the specified type. |
Gets a collection of initialized objects from the application context
that are assignable from
public IEnumerable GetObjectsOfContextAssignableFrom<T>()
A collection of initialized application context objects.
Gets a collection of initialized objects from the application context that are assignable from type.
public IEnumerable<Object> GetObjectsOfContextAssignableFrom(type)
A collection of initialized application context objects.
Name | Type | Summary |
---|---|---|
type | Type | Type that the objects must be assignable from. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when type is null. |
Gets the Type of the object for the given name.
public Type GetType(name)
Type of the object for the given name.
Name | Type | Summary |
---|---|---|
name | String | The name of the object to retrive it's type. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
NoSuchObjectException | Thrown when there are no object for the given name. |
Initialize this object factory from the enumeration of configured objects.
protected Void InitializeFactory(name, config)
Name | Type | Summary |
---|---|---|
name | String | Name of this factory. |
config | IEnumerable<ObjectConfiguration> | A collection of object configuration for this factory. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
ArgumentNullException | Thown when config is null. |
Inject dependencies into o.
public Void InjectDependencies(name, o)
Name | Type | Summary |
---|---|---|
name | String | The name of the application context object. |
o | Object | An object to inject dependencies into. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
ArgumentNullException | Thrown when o is null. |
NoSuchObjectException | Thrown when there are no object for the given name. |
DependencyInjectionException | Thrown when an error occurs while injecting dependencies. |
Inject dependencies into o.
protected Void InjectDependencies(cfg, o)
Name | Type | Summary |
---|---|---|
cfg | ObjectConfiguration | Object configuration. |
o | Object | An object to inject dependencies into. |
Type | Summary |
---|---|
ArgumentNullException | Thrown when any of the arguments is null. |
DependencyInjectionException | Thrown when an error occurs while injecting dependencies. |
Finds out whether the object for the given name is a singleton.
public Boolean IsSingleton(name)
true if the object is a singleton.
Name | Type | Summary |
---|---|---|
name | String | The name of the object. |
Type | Summary |
---|---|
ArgumentNullOrEmptyException | Thrown when name is null or empty. |
NoSuchObjectException | Thrown when there are no object for the given name. |
Returns a textual representation of the object factory.
public String ToString()
In this document