C# Class Rock.Attribute.Helper

Static Helper class for creating, saving, and reading attributes and attribute values of any IHasAttributes class
Exibir arquivo Open project: NewSpring/Rock

Public Methods

Method Description
AddDisplayControls ( IHasAttributes item, Control parentControl, List exclude = null, bool supressOrdering = false, bool showHeading = true ) : void

Gets the display HTML.

AddDisplayControls ( IHasAttributes item, List attributeCategories, Control parentControl, List exclude = null, bool showHeading = true ) : void

Adds the display controls.

AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, List exclude, bool supressOrdering = false ) : void

Adds edit controls for each of the item's attributes

AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, List exclude, bool supressOrdering, int numberOfColumns = null ) : void

Adds the edit controls.

AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup = "", bool supressOrdering = false ) : void

Adds edit controls for each of the item's attributes

AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, int numberOfColumns ) : void

Adds the edit controls.

AddEditControls ( string category, List attributeKeys, IHasAttributes item, Control parentControl, string validationGroup, bool setValue, List exclude ) : void

Adds the edit controls.

AddEditControls ( string category, List attributeKeys, IHasAttributes item, Control parentControl, string validationGroup, bool setValue, List exclude, int numberOfColumns ) : void

Adds the edit controls.

CopyAttributes ( IHasAttributes source, IHasAttributes target ) : void

Copies the attributes from one entity to another

GetAttributeCategories ( IHasAttributes entity, bool onlyIncludeGridColumns = false, bool allowMultiple = false, bool supressOrdering = false ) : List

Gets the attribute categories.

GetAttributeCategories ( List attributes, bool onlyIncludeGridColumns = false, bool allowMultiple = false ) : List

Gets attributes grouped by category

GetAttributeValueExpression ( IQueryable attributeValues, ParameterExpression attributeValueParameter, Expression parentIdProperty, int attributeId ) : Expression

Gets the attribute value expression.

GetEditValues ( Control parentControl, IHasAttributes item ) : void

Gets the edit values.

LoadAttributes ( Rock entity ) : void

Loads the P:IHasAttributes.Attributes and P:IHasAttributes.AttributeValues of any IHasAttributes object

LoadAttributes ( Rock entity, RockContext rockContext ) : void

Loads the P:IHasAttributes.Attributes and P:IHasAttributes.AttributeValues of any IHasAttributes object

SaveAttributeEdits ( AttributeEditor edtAttribute, int entityTypeId, string entityTypeQualifierColumn, string entityTypeQualifierValue, RockContext rockContext = null ) : Rock.Model.Attribute

Saves any attribute edits made using an Attribute Editor control

If a rockContext value is included, this method will save any previous changes made to the context

SaveAttributeEdits ( Rock newAttribute, int entityTypeId, string entityTypeQualifierColumn, string entityTypeQualifierValue, RockContext rockContext = null ) : Rock.Model.Attribute

Saves any attribute edits made to an attribute. Note: any attributes will be flushed from the cache. Be sure to either reload the cache or the individual attribute when you are done.

If a rockContext value is included, this method will save any previous changes made to the context

SaveAttributeValue ( IHasAttributes model, Rock attribute, string newValue, RockContext rockContext = null ) : void

Saves an attribute value.

If a rockContext value is included, this method will save any previous changes made to the context

SaveAttributeValue ( int entityId, Rock attribute, string newValue, RockContext rockContext = null ) : void

Saves the attribute value.

If a rockContext value is included, this method will save any previous changes made to the context

SaveAttributeValues ( IHasAttributes model, RockContext rockContext = null ) : void

Saves the attribute values.

If a rockContext value is included, this method will save any previous changes made to the context

UpdateAttributes ( Type type, int entityTypeId, RockContext rockContext = null ) : bool

Updates the attributes.

If a rockContext value is included, this method will save any previous changes made to the context

UpdateAttributes ( Type type, int entityTypeId, string entityQualifierColumn, string entityQualifierValue, RockContext rockContext = null ) : bool

Uses reflection to find any FieldAttribute attributes for the specified type and will create and/or update a Rock.Model.Attribute record for each attribute defined.

If a rockContext value is included, this method will save any previous changes made to the context

Private Methods

Method Description
AddAttributeCategory ( List attributeCategories, Rock category, Rock attribute ) : void
UpdateAttribute ( FieldAttribute property, int entityTypeId, string entityQualifierColumn, string entityQualifierValue, RockContext rockContext = null ) : bool

Adds or Updates a Rock.Model.Attribute item for the attribute.

If a rockContext value is included, this method will save any previous changes made to the context

Method Details

AddDisplayControls() public static method

Gets the display HTML.
public static AddDisplayControls ( IHasAttributes item, Control parentControl, List exclude = null, bool supressOrdering = false, bool showHeading = true ) : void
item IHasAttributes The item.
parentControl Control The parent control.
exclude List The exclude.
supressOrdering bool if set to true supresses reording (LoadAttributes() may perform custom ordering as is the case for group member attributes).
showHeading bool if set to true [show heading].
return void

AddDisplayControls() public static method

Adds the display controls.
public static AddDisplayControls ( IHasAttributes item, List attributeCategories, Control parentControl, List exclude = null, bool showHeading = true ) : void
item IHasAttributes The item.
attributeCategories List The attribute categories.
parentControl Control The parent control.
exclude List The exclude.
showHeading bool if set to true [show heading].
return void

AddEditControls() public static method

Adds edit controls for each of the item's attributes
public static AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, List exclude, bool supressOrdering = false ) : void
item IHasAttributes The item.
parentControl Control The parent control.
setValue bool if set to true [set value].
validationGroup string The validation group.
exclude List List of attribute names not to render
supressOrdering bool if set to true supresses reording (LoadAttributes() may perform custom ordering as is the case for group member attributes).
return void

AddEditControls() public static method

Adds the edit controls.
public static AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, List exclude, bool supressOrdering, int numberOfColumns = null ) : void
item IHasAttributes The item.
parentControl Control The parent control.
setValue bool if set to true [set value].
validationGroup string The validation group.
exclude List The exclude.
supressOrdering bool if set to true [supress ordering].
numberOfColumns int The number of columns.
return void

AddEditControls() public static method

Adds edit controls for each of the item's attributes
public static AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup = "", bool supressOrdering = false ) : void
item IHasAttributes The item.
parentControl Control The parent control.
setValue bool if set to true [set value].
validationGroup string The validation group.
supressOrdering bool if set to true supresses reording (LoadAttributes() may perform custom ordering as is the case for group member attributes).
return void

AddEditControls() public static method

Adds the edit controls.
public static AddEditControls ( IHasAttributes item, Control parentControl, bool setValue, string validationGroup, int numberOfColumns ) : void
item IHasAttributes The item.
parentControl Control The parent control.
setValue bool if set to true [set value].
validationGroup string The validation group.
numberOfColumns int The number of columns.
return void

AddEditControls() public static method

Adds the edit controls.
public static AddEditControls ( string category, List attributeKeys, IHasAttributes item, Control parentControl, string validationGroup, bool setValue, List exclude ) : void
category string The category.
attributeKeys List The attribute keys.
item IHasAttributes The item.
parentControl Control The parent control.
validationGroup string The validation group.
setValue bool if set to true [set value].
exclude List The exclude.
return void

AddEditControls() public static method

Adds the edit controls.
public static AddEditControls ( string category, List attributeKeys, IHasAttributes item, Control parentControl, string validationGroup, bool setValue, List exclude, int numberOfColumns ) : void
category string The category.
attributeKeys List The attribute keys.
item IHasAttributes The item.
parentControl Control The parent control.
validationGroup string The validation group.
setValue bool if set to true [set value].
exclude List The exclude.
numberOfColumns int The number of columns.
return void

CopyAttributes() public static method

Copies the attributes from one entity to another
public static CopyAttributes ( IHasAttributes source, IHasAttributes target ) : void
source IHasAttributes The source.
target IHasAttributes The target.
return void

GetAttributeCategories() public static method

Gets the attribute categories.
public static GetAttributeCategories ( IHasAttributes entity, bool onlyIncludeGridColumns = false, bool allowMultiple = false, bool supressOrdering = false ) : List
entity IHasAttributes The entity.
onlyIncludeGridColumns bool if set to true will only include those attributes with the option to display in grid set to true
allowMultiple bool if set to true returns the attribute in each of its categories, if false, only returns attribut in first category.
supressOrdering bool if set to true supresses reording (LoadAttributes() may perform custom ordering as is the case for group member attributes).
return List

GetAttributeCategories() public static method

Gets attributes grouped by category
public static GetAttributeCategories ( List attributes, bool onlyIncludeGridColumns = false, bool allowMultiple = false ) : List
attributes List The attributes.
onlyIncludeGridColumns bool if set to true will only include those attributes with the option to display in grid set to true
allowMultiple bool if set to true returns the attribute in each of its categories, if false, only returns attribut in first category.
return List

GetAttributeValueExpression() public static method

Gets the attribute value expression.
public static GetAttributeValueExpression ( IQueryable attributeValues, ParameterExpression attributeValueParameter, Expression parentIdProperty, int attributeId ) : Expression
attributeValues IQueryable The attribute values.
attributeValueParameter ParameterExpression The attribute value parameter.
parentIdProperty Expression The parent identifier property.
attributeId int The attribute identifier.
return Expression

GetEditValues() public static method

Gets the edit values.
public static GetEditValues ( Control parentControl, IHasAttributes item ) : void
parentControl Control The parent control.
item IHasAttributes The item.
return void

LoadAttributes() public static method

Loads the P:IHasAttributes.Attributes and P:IHasAttributes.AttributeValues of any IHasAttributes object
public static LoadAttributes ( Rock entity ) : void
entity Rock The item.
return void

LoadAttributes() public static method

Loads the P:IHasAttributes.Attributes and P:IHasAttributes.AttributeValues of any IHasAttributes object
public static LoadAttributes ( Rock entity, RockContext rockContext ) : void
entity Rock The item.
rockContext RockContext The rock context.
return void

SaveAttributeEdits() public static method

Saves any attribute edits made using an Attribute Editor control
If a rockContext value is included, this method will save any previous changes made to the context
public static SaveAttributeEdits ( AttributeEditor edtAttribute, int entityTypeId, string entityTypeQualifierColumn, string entityTypeQualifierValue, RockContext rockContext = null ) : Rock.Model.Attribute
edtAttribute AttributeEditor The edt attribute.
entityTypeId int The entity type identifier.
entityTypeQualifierColumn string The entity type qualifier column.
entityTypeQualifierValue string The entity type qualifier value.
rockContext RockContext The rock context.
return Rock.Model.Attribute

SaveAttributeEdits() public static method

Saves any attribute edits made to an attribute. Note: any attributes will be flushed from the cache. Be sure to either reload the cache or the individual attribute when you are done.
If a rockContext value is included, this method will save any previous changes made to the context
public static SaveAttributeEdits ( Rock newAttribute, int entityTypeId, string entityTypeQualifierColumn, string entityTypeQualifierValue, RockContext rockContext = null ) : Rock.Model.Attribute
newAttribute Rock The new attribute.
entityTypeId int The entity type identifier.
entityTypeQualifierColumn string The entity type qualifier column.
entityTypeQualifierValue string The entity type qualifier value.
rockContext RockContext The rock context.
return Rock.Model.Attribute

SaveAttributeValue() public static method

Saves an attribute value.
If a rockContext value is included, this method will save any previous changes made to the context
public static SaveAttributeValue ( IHasAttributes model, Rock attribute, string newValue, RockContext rockContext = null ) : void
model IHasAttributes The model.
attribute Rock The attribute.
newValue string The new value.
rockContext RockContext The rock context.
return void

SaveAttributeValue() public static method

Saves the attribute value.
If a rockContext value is included, this method will save any previous changes made to the context
public static SaveAttributeValue ( int entityId, Rock attribute, string newValue, RockContext rockContext = null ) : void
entityId int The entity identifier.
attribute Rock The attribute.
newValue string The new value.
rockContext RockContext The rock context.
return void

SaveAttributeValues() public static method

Saves the attribute values.
If a rockContext value is included, this method will save any previous changes made to the context
public static SaveAttributeValues ( IHasAttributes model, RockContext rockContext = null ) : void
model IHasAttributes The model.
rockContext RockContext The rock context.
return void

UpdateAttributes() public static method

Updates the attributes.
If a rockContext value is included, this method will save any previous changes made to the context
public static UpdateAttributes ( Type type, int entityTypeId, RockContext rockContext = null ) : bool
type Type The type (should be a object.
entityTypeId int The entity type id.
rockContext RockContext The rock context.
return bool

UpdateAttributes() public static method

Uses reflection to find any FieldAttribute attributes for the specified type and will create and/or update a Rock.Model.Attribute record for each attribute defined.
If a rockContext value is included, this method will save any previous changes made to the context
public static UpdateAttributes ( Type type, int entityTypeId, string entityQualifierColumn, string entityQualifierValue, RockContext rockContext = null ) : bool
type Type The type (should be a object.
entityTypeId int The entity type id.
entityQualifierColumn string The entity qualifier column.
entityQualifierValue string The entity qualifier value.
rockContext RockContext The rock context.
return bool