C# Class Spring.Objects.ObjectWrapper

Inheritance: IObjectWrapper
Show file Open project: spring-projects/spring-net Class Usage Examples

Public Methods

Method Description
GetPropertyInfo ( string propertyName ) : PropertyInfo

Returns PropertyInfo for the specified property

GetPropertyInfos ( ) : System.Reflection.PropertyInfo[]

Get the properties of the wrapped object.

GetPropertyType ( string propertyName ) : Type

Get the System.Type for a particular property.

GetPropertyValue ( IExpression propertyExpression ) : object

Gets the value of a property.

GetPropertyValue ( string propertyName ) : object

Gets the value of a property.

ObjectWrapper ( ) : System

Creates a new instance of the Spring.Objects.ObjectWrapper class.

The wrapped target instance will need to be set afterwards.

ObjectWrapper ( Type type ) : System

Creates a new instance of the Spring.Objects.ObjectWrapper class, instantiating a new instance of the specified System.Type and using it as the Spring.Objects.ObjectWrapper.WrappedInstance.

Please note that the System.Type passed as the type argument must have a no-argument constructor. If it does not, an exception will be thrown when this class attempts to instantiate the supplied type using it's (non-existent) constructor.

ObjectWrapper ( object instance ) : System

Creates a new instance of the Spring.Objects.ObjectWrapper class.

SetPropertyValue ( IExpression propertyExpression, object val ) : void

Sets a property value.

SetPropertyValue ( Spring.Objects.PropertyValue pv ) : void

Sets a property value.

This is the preferred way to update an individual property.

SetPropertyValue ( string propertyName, object val ) : void

Sets a property value.

This method is provided for convenience only. The Spring.Objects.ObjectWrapper.SetPropertyValue(PropertyValue) method is more powerful.

SetPropertyValues ( IPropertyValues pvs ) : void

Set a number of property values in bulk.

Does not allow unknown fields. Equivalent to Spring.Objects.ObjectWrapper.SetPropertyValues(IPropertyValues, bool) with and for arguments.

SetPropertyValues ( IPropertyValues propertyValues, bool ignoreUnknown ) : void

Perform a bulk update with full control over behavior.

This method may throw a reflection-based exception, if there is a critical failure such as no matching field... less serious exceptions will be accumulated and thrown as a single Spring.Objects.PropertyAccessExceptionsException.

ToString ( ) : string

This method is expensive! Only call for diagnostics and debugging reasons, not in production.

Private Methods

Method Description
GetPropertyExpression ( string propertyName ) : IExpression

Attempts to parse property expression first and falls back to full expression if that fails. Performance optimization.

GetPropertyOrFieldInfo ( string propertyOrFieldName ) : MemberInfo

Returns MemberInfo for the specified property or field

Method Details

GetPropertyInfo() public method

Returns PropertyInfo for the specified property
If cannot be determined.
public GetPropertyInfo ( string propertyName ) : PropertyInfo
propertyName string The name of the property to search for.
return System.Reflection.PropertyInfo

GetPropertyInfos() public method

Get the properties of the wrapped object.
public GetPropertyInfos ( ) : System.Reflection.PropertyInfo[]
return System.Reflection.PropertyInfo[]

GetPropertyType() public method

Get the System.Type for a particular property.
public GetPropertyType ( string propertyName ) : Type
propertyName string /// The property the of which is to be retrieved. ///
return System.Type

GetPropertyValue() public method

Gets the value of a property.
/// If there is no such property, if the property isn't readable, or /// if getting the property value throws an exception. ///
public GetPropertyValue ( IExpression propertyExpression ) : object
propertyExpression IExpression /// The property expression that should be used to retrieve the property value. ///
return object

GetPropertyValue() public method

Gets the value of a property.
/// If there is no such property, if the property isn't readable, or /// if getting the property value throws an exception. ///
public GetPropertyValue ( string propertyName ) : object
propertyName string /// The name of the property to get the value of. ///
return object

ObjectWrapper() public method

Creates a new instance of the Spring.Objects.ObjectWrapper class.

The wrapped target instance will need to be set afterwards.

public ObjectWrapper ( ) : System
return System

ObjectWrapper() public method

Creates a new instance of the Spring.Objects.ObjectWrapper class, instantiating a new instance of the specified System.Type and using it as the Spring.Objects.ObjectWrapper.WrappedInstance.

Please note that the System.Type passed as the type argument must have a no-argument constructor. If it does not, an exception will be thrown when this class attempts to instantiate the supplied type using it's (non-existent) constructor.

/// If the is , or if the /// invocation of the s default (no-arg) constructor /// fails (due to invalid arguments, insufficient permissions, etc). ///
public ObjectWrapper ( Type type ) : System
type System.Type /// The to instantiate and wrap. ///
return System

ObjectWrapper() public method

Creates a new instance of the Spring.Objects.ObjectWrapper class.
/// If the supplied is . ///
public ObjectWrapper ( object instance ) : System
instance object /// The object wrapped by this . ///
return System

SetPropertyValue() public method

Sets a property value.
public SetPropertyValue ( IExpression propertyExpression, object val ) : void
propertyExpression IExpression /// The property expression that should be used to set the property value. ///
val object The new value.
return void

SetPropertyValue() public method

Sets a property value.

This is the preferred way to update an individual property.

public SetPropertyValue ( Spring.Objects.PropertyValue pv ) : void
pv Spring.Objects.PropertyValue /// The object containing new property value. ///
return void

SetPropertyValue() public method

Sets a property value.

This method is provided for convenience only. The Spring.Objects.ObjectWrapper.SetPropertyValue(PropertyValue) method is more powerful.

public SetPropertyValue ( string propertyName, object val ) : void
propertyName string /// The name of the property to set value of. ///
val object The new value.
return void

SetPropertyValues() public method

Set a number of property values in bulk.

Does not allow unknown fields. Equivalent to Spring.Objects.ObjectWrapper.SetPropertyValues(IPropertyValues, bool) with and for arguments.

/// If an error is encountered while setting a property. /// /// On a mismatch while setting a property, insufficient permissions, etc. ///
public SetPropertyValues ( IPropertyValues pvs ) : void
pvs IPropertyValues /// The to set on the target /// object. ///
return void

SetPropertyValues() public method

Perform a bulk update with full control over behavior.

This method may throw a reflection-based exception, if there is a critical failure such as no matching field... less serious exceptions will be accumulated and thrown as a single Spring.Objects.PropertyAccessExceptionsException.

/// If an error is encountered while setting a property (only thrown if the /// parameter is set to ). /// /// On a mismatch while setting a property, insufficient permissions, etc. ///
public SetPropertyValues ( IPropertyValues propertyValues, bool ignoreUnknown ) : void
propertyValues IPropertyValues /// The s to set on the target object. ///
ignoreUnknown bool /// Should we ignore unknown values (not found in the object!?). ///
return void

ToString() public method

This method is expensive! Only call for diagnostics and debugging reasons, not in production.
public ToString ( ) : string
return string