Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

FieldRetrievingFactoryObject Class

IFactoryObject implementation that retrieves a static or non-static public field value.

For a list of all members of this type, see FieldRetrievingFactoryObject Members .


[Visual Basic]
<Serializable> _
Public Class FieldRetrievingFactoryObject
    Implements IFactoryObject, IInitializingObject, IObjectNameAware
public class FieldRetrievingFactoryObject : IFactoryObject, IInitializingObject, IObjectNameAware

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


Typically used for retrieving public constants.


The following example retrieves the Value field value...

  <object id="dbnull" type="Spring.Objects.Factory.Config.FieldRetrievingFactoryObject, Spring.Core">
    <property name="TargetType" value="System.DBNull" />
    <property name="TargetField" value="Value" />

The previous example could also have been written using the convenience StaticField property, like so...

  <object id="dbnull" type="Spring.Objects.Factory.Config.FieldRetrievingFactoryObject, Spring.Core">
    <property name="StaticField" value="System.DBNull.Value" />

This class also implements the IObjectNameAware interface (ObjectName). If the id (or name) of one's FieldRetrievingFactoryObject object definition is set to the AssemblyQualifiedName of the static (Shared in Visual Basic) field to be retrieved, then the id (or name) of one's object definition will be used for the name of the static (Shared in Visual Basic) field lookup. See below for an example of this concise style of definition.

  <!-- returns the value of the DBNull.Value field -->
  <object id="System.DBNull.Value" type="Spring.Objects.Factory.Config.FieldRetrievingFactoryObject, Spring.Core" />
  <!-- returns the value of the Type.Delimiter field -->
  <object id="System.Type.Delimiter" type="Spring.Objects.Factory.Config.FieldRetrievingFactoryObject, Spring.Core" />

The usage for retrieving instance fields is similar. No example is shown because public instance fields are generally bad practice; but if you have some legacy code that exposes public instance fields, or if you just really like coding public instance fields, then you can use this IFactoryObject implementation to retrieve such field values.


Namespace: Spring.Objects.Factory.Config

Assembly: Spring.Core (in Spring.Core.dll)

See Also

FieldRetrievingFactoryObject Members | Spring.Objects.Factory.Config Namespace