C# Class Habanero.Faces.Base.ControlMapper

A superclass to model a mapper that wraps a control in order to display and capture information for an individual property of a Business Object. Think of the Control Mappers as Binding on Steriods.
Inheritance: IControlMapper
Afficher le fichier Open project: Chillisoft/habanero.faces Class Usage Examples

Protected Properties

Свойство Type Description
_attributes System.Collections.Hashtable
_businessObject IBusinessObject
_logger IHabaneroLogger

Private Properties

Свойство Type Description
AddCurrentBOPropHandlers void
AddKeyPressHandlers void
CheckReadWriteRules bool
DoesVirtualPropertyHaveSetter bool
IsPropertyReflective bool
IsPropertyViaRelationship bool
IsTypeOfIControlMapper bool
RemoveCurrentBOPropHandlers void

Méthodes publiques

Méthode Description
ApplyChangesToBusinessObject ( ) : void

Updates the properties on the represented business object

BOPropValueUpdatedHandler ( object sender, EventArgs e ) : void

Handler to carry out changes where the value of a business object property has changed

Create ( IControlHabanero ctl, string propertyName ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

Create ( Type mapperType, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper

Create a Control Mapper based on the mapperType

Create ( string mapperTypeName, IControlHabanero ctl, string propertyName ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

Create ( string mapperTypeName, string mapperAssembly, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.

CurrentBOProp ( ) : IBOProp

Returns the IBOProp object being mapped to this control

GetErrorMessage ( ) : string

Returns the Error Provider's Error message.

SetPropertyAttributes ( Hashtable attributes ) : void

A form field can have attributes defined in the class definition. These attributes are passed to the control mapper via a hashtable so that the control mapper can adjust its behaviour accordingly.

UpdateControlValueFromBusinessObject ( ) : void

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject. This also updates the Error Provider with any Error Messages.

UpdateErrorProviderErrorMessage ( ) : void

Sets the Error Provider Error with the appropriate value for the property e.g. if it is invalid then sets the error provider with the invalid reason else sets the error provider with a zero length string.

Méthodes protégées

Méthode Description
ControlMapper ( IControlHabanero ctl, string propName, bool isReadOnly, IControlFactory factory ) : System

Constructor to instantiate a new instance of the class

GetPropertyValue ( ) : object

Returns the property value of the business object being mapped

InitialiseWithAttributes ( ) : void

Initialises the control using the attributes already provided, using SetPropertyAttributes.

InternalUpdateControlValueFromBo ( ) : void

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject.

IsPropertyVirtual ( ) : bool

is the property a virtual property i.e. is it loaded via reflection or via a relationship.

OnBusinessObjectChanged ( ) : void

An overridable method to provide custom logic to carry out when the business object is changed

SetError ( string errorMessage ) : void
SetPropertyValue ( object value ) : void

Sets the property value to that provided. If the property value is invalid, the error provider will be given the reason why the value is invalid.

UpdateControlVisualState ( bool editable ) : void

Update the Visual state of the control so as to differentiate between Editable and none editable controls.

UpdateIsEditable ( ) : void

Updates the isEditable flag and updates the control according to the current state

Private Methods

Méthode Description
AddCurrentBOPropHandlers ( ) : void
AddKeyPressHandlers ( ) : void
CheckReadWriteRules ( ) : bool
DoesVirtualPropertyHaveSetter ( ) : bool
IsPropertyReflective ( ) : bool
IsPropertyViaRelationship ( ) : bool
IsTypeOfIControlMapper ( Type mapperType ) : bool
RemoveCurrentBOPropHandlers ( ) : void

Method Details

ApplyChangesToBusinessObject() public abstract méthode

Updates the properties on the represented business object
public abstract ApplyChangesToBusinessObject ( ) : void
Résultat void

BOPropValueUpdatedHandler() public méthode

Handler to carry out changes where the value of a business object property has changed
public BOPropValueUpdatedHandler ( object sender, EventArgs e ) : void
sender object The object that notified of the event
e System.EventArgs Attached arguments regarding the event
Résultat void

ControlMapper() protected méthode

Constructor to instantiate a new instance of the class
protected ControlMapper ( IControlHabanero ctl, string propName, bool isReadOnly, IControlFactory factory ) : System
ctl IControlHabanero The control object to map
propName string The property name
isReadOnly bool Whether the control is read only. /// If so, it then becomes disabled. If not, /// handlers are assigned to manage key presses.
factory IControlFactory
Résultat System

Create() public static méthode

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( IControlHabanero ctl, string propertyName ) : IControlMapper
ctl IControlHabanero The control to be mapped
propertyName string The property name
Résultat IControlMapper

Create() public static méthode

Create a Control Mapper based on the mapperType
public static Create ( Type mapperType, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper
mapperType System.Type
ctl IControlHabanero The control to be mapped
propertyName string The property name
isReadOnly bool Whether the control is read-only
controlFactory IControlFactory The control factory that is being set on the Mapper
Résultat IControlMapper

Create() public static méthode

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( string mapperTypeName, IControlHabanero ctl, string propertyName ) : IControlMapper
mapperTypeName string The class name of the mapper type /// (e.g. ComboBoxMapper). The current namespace of this /// ControlMapper class will then be prefixed to the name.
ctl IControlHabanero The control to be mapped
propertyName string The property name
Résultat IControlMapper

Create() public static méthode

Creates a new control mapper of a specified type. If no 'mapperTypeName' has been specified, an appropriate mapper for standard controls will be assigned, depending on the type of control.
An exception is /// thrown if the mapperTypeName does not provide a type that is /// a subclass of the ControlMapper class.
public static Create ( string mapperTypeName, string mapperAssembly, IControlHabanero ctl, string propertyName, bool isReadOnly, IControlFactory controlFactory ) : IControlMapper
mapperTypeName string The class name of the mapper type /// (e.g. ComboBoxMapper). The current namespace of this /// ControlMapper class will then be prefixed to the name.
mapperAssembly string The assembly where the mapper is /// located
ctl IControlHabanero The control to be mapped
propertyName string The property name
isReadOnly bool Whether the control is read-only
controlFactory IControlFactory The control factory
Résultat IControlMapper

CurrentBOProp() public méthode

Returns the IBOProp object being mapped to this control
public CurrentBOProp ( ) : IBOProp
Résultat IBOProp

GetErrorMessage() public méthode

Returns the Error Provider's Error message.
public GetErrorMessage ( ) : string
Résultat string

GetPropertyValue() protected méthode

Returns the property value of the business object being mapped
protected GetPropertyValue ( ) : object
Résultat object

InitialiseWithAttributes() protected méthode

Initialises the control using the attributes already provided, using SetPropertyAttributes.
protected InitialiseWithAttributes ( ) : void
Résultat void

InternalUpdateControlValueFromBo() protected abstract méthode

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject.
protected abstract InternalUpdateControlValueFromBo ( ) : void
Résultat void

IsPropertyVirtual() protected méthode

is the property a virtual property i.e. is it loaded via reflection or via a relationship.
protected IsPropertyVirtual ( ) : bool
Résultat bool

OnBusinessObjectChanged() protected méthode

An overridable method to provide custom logic to carry out when the business object is changed
protected OnBusinessObjectChanged ( ) : void
Résultat void

SetError() protected méthode

protected SetError ( string errorMessage ) : void
errorMessage string
Résultat void

SetPropertyAttributes() public méthode

A form field can have attributes defined in the class definition. These attributes are passed to the control mapper via a hashtable so that the control mapper can adjust its behaviour accordingly.
public SetPropertyAttributes ( Hashtable attributes ) : void
attributes System.Collections.Hashtable A hashtable of attributes, which consists /// of name-value pairs, where name is the attribute name. This is usually /// set in the XML definitions for the class's user interface.
Résultat void

SetPropertyValue() protected méthode

Sets the property value to that provided. If the property value is invalid, the error provider will be given the reason why the value is invalid.
protected SetPropertyValue ( object value ) : void
value object
Résultat void

UpdateControlValueFromBusinessObject() public méthode

Updates the value on the control from the corresponding property on the represented IControlMapper.BusinessObject. This also updates the Error Provider with any Error Messages.
public UpdateControlValueFromBusinessObject ( ) : void
Résultat void

UpdateControlVisualState() protected méthode

Update the Visual state of the control so as to differentiate between Editable and none editable controls.
protected UpdateControlVisualState ( bool editable ) : void
editable bool
Résultat void

UpdateErrorProviderErrorMessage() public méthode

Sets the Error Provider Error with the appropriate value for the property e.g. if it is invalid then sets the error provider with the invalid reason else sets the error provider with a zero length string.
public UpdateErrorProviderErrorMessage ( ) : void
Résultat void

UpdateIsEditable() protected méthode

Updates the isEditable flag and updates the control according to the current state
protected UpdateIsEditable ( ) : void
Résultat void

Property Details

_attributes protected_oe property

A Hash table of additional Attributes available for this Control Mapper e.g. for DateTimePickerMapper may have date format
protected Hashtable,System.Collections _attributes
Résultat System.Collections.Hashtable

_businessObject protected_oe property

The Business Object being mapped
protected IBusinessObject _businessObject
Résultat IBusinessObject

_logger protected_oe static_oe property

the ILog used to log any messages for this class or its children
protected static IHabaneroLogger _logger
Résultat IHabaneroLogger