Class AbstractInfoBase<TInfo>
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Abstract object info class.
public abstract class AbstractInfoBase<TInfo> : BaseInfo, IExtensible, IInfo, IAdvancedDataContainer, ICMSObject, IHierarchicalDataContainer, IDataContainer, ISimpleDataContainer, IVirtualHierarchicalObject, IHierarchicalObject, INameIndexable, IMacroObject where TInfo : AbstractInfoBase<TInfo>, new()
Type Parameters
TInfo
- Inheritance
-
objectAbstractInfoBase<TInfo>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
AbstractInfoBase()
Constructor.
protected AbstractInfoBase()
AbstractInfoBase(IDataClass)
Constructor - Initializes the object with source data.
protected AbstractInfoBase(IDataClass sourceData)
Parameters
sourceDataIDataClassSource data
AbstractInfoBase(ObjectTypeInfo)
Constructor - Initializes the type dependent values.
protected AbstractInfoBase(ObjectTypeInfo typeInfo)
Parameters
typeInfoObjectTypeInfoType information
AbstractInfoBase(ObjectTypeInfo, IDataClass, bool)
Constructor - Initializes the object with source data.
protected AbstractInfoBase(ObjectTypeInfo typeInfo, IDataClass sourceData, bool keepSourceData)
Parameters
typeInfoObjectTypeInfoType information
sourceDataIDataClassSource data
keepSourceDataboolIf true, source data are kept
AbstractInfoBase(ObjectTypeInfo, bool)
Constructor - Initializes the type dependent values.
protected AbstractInfoBase(ObjectTypeInfo typeInfo, bool createData)
Parameters
typeInfoObjectTypeInfoType information
createDataboolIf true, data structure of the object is created
AbstractInfoBase(ObjectTypeInfo, DataRow)
Constructor - Initializes the type dependent values.
protected AbstractInfoBase(ObjectTypeInfo typeInfo, DataRow dr)
Parameters
typeInfoObjectTypeInfoType information
drDataRowDataRow with the source data
Fields
mCombinedColumnNames
Column names, cached either by call to CombineColumnNames(params string[]) (or its override) or in the code of inherited class.
[Obsolete("Property was not intended for public use and will be removed.")]
protected static List<string> mCombinedColumnNames
Field Value
- List<string>
- See Also
mGenerator
Object generator
protected static ObjectGenerator<TInfo> mGenerator
Field Value
- ObjectGenerator<TInfo>
Properties
ClassName
Returns the class name of this object
[DatabaseMapping(false)]
public virtual string ClassName { get; }
Property Value
- string
ClearCacheMethods
Dictionary with the methods for clearing the internal object cache [columnName] => [clearCacheAction]
protected override sealed IDictionary<string, Action<BaseInfo>> ClearCacheMethods { get; }
Property Value
- IDictionary<string, Action<BaseInfo>>
ColumnNames
Column names.
public override sealed List<string> ColumnNames { get; }
Property Value
- List<string>
Remarks
Consists of column names for this class and column names for this particular object.
DataClass
Data class with the info object data.
protected virtual IDataClass DataClass { get; set; }
Property Value
DataClassDataStore
Gets the IDataClassDataStore to be used when storing the data.
protected virtual IDataClassDataStore DataClassDataStore { get; }
Property Value
Generalized
Generalized interface of this object.
public GeneralizedAbstractInfo<TInfo> Generalized { get; }
Property Value
- GeneralizedAbstractInfo<TInfo>
HasChanged
Returns true if the object changed.
public override bool HasChanged { get; }
Property Value
- bool
HasData
Returns true if the object has it's data storage initialized already
protected override bool HasData { get; }
Property Value
- bool
IsComplete
Returns true if the object is complete (has all columns).
public override bool IsComplete { get; }
Property Value
- bool
OriginalObjectCodeName
Returns the original object code name
protected virtual string OriginalObjectCodeName { get; }
Property Value
- string
Properties
Properties of the object
public override List<string> Properties { get; }
Property Value
- List<string>
RegisteredProperties
Registered properties
protected virtual RegisteredProperties<TInfo> RegisteredProperties { get; }
Property Value
- RegisteredProperties<TInfo>
Methods
AnyItemChanged(params string[])
Returns true if any of specified columns changed.
public bool AnyItemChanged(params string[] columnNames)
Parameters
columnNamesstring[]Column names
Returns
- bool
ChangedColumns()
Returns list of column names which values were changed.
public override List<string> ChangedColumns()
Returns
- List<string>
List of column names
Clone()
Creates a clone of the object
public virtual TInfo Clone()
Returns
- TInfo
Clone(bool)
Creates a clone of the object
public virtual TInfo Clone(bool clear)
Parameters
clearboolIf true, the object is cleared to be able to create new object
Returns
- TInfo
CloneObject(bool)
Creates the clone of the object
public override BaseInfo CloneObject(bool clear = false)
Parameters
clearboolIf true, the object is cleared to be able to create new object
Returns
CombineColumnNames(params ICollection[])
Combines column names from supplied collections into a list and caches it in mCombinedColumnNames. Does nothing when column names are already cached unless TypeInfo has ColumnsInvalidated set to true. Returns combined column names.
[Obsolete("Method was not intended for public use and will be removed.")]
protected List<string> CombineColumnNames(params ICollection[] names)
Parameters
namesICollection[]An array of collections containing column names.
Returns
- List<string>
Combined column names.
- See Also
CombineColumnNames(params string[])
Combines supplied column names into a list and caches it in mCombinedColumnNames. Does nothing when column names are already cached unless TypeInfo has ColumnsInvalidated set to true. Returns combined column names.
[Obsolete("Method was not intended for public use and will be removed.")]
public List<string> CombineColumnNames(params string[] names)
Parameters
namesstring[]A string array containing column names.
Returns
- List<string>
Combined column names.
- See Also
ContainsColumn(string)
Returns true if the object contains given column.
public override bool ContainsColumn(string columnName)
Parameters
columnNamestringColumn name
Returns
- bool
CopyProperties(TInfo)
Copies memory properties
protected virtual void CopyProperties(TInfo infoObj)
Parameters
infoObjTInfoTarget object instance
DataChanged(string)
Returns true if the object changed.
public override bool DataChanged(string excludedColumns)
Parameters
excludedColumnsstringList of columns excluded from change (separated by ';')
Returns
- bool
DeleteData()
Deletes the object from the database.
protected virtual void DeleteData()
DeleteDataAsync(CancellationToken)
Asynchronously deletes the object from the database.
protected virtual Task DeleteDataAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
DeleteDataInternal()
Deletes the object data from the database.
protected virtual void DeleteDataInternal()
- See Also
DeleteDataInternalAsync(CancellationToken)
Asynchronously deletes the object data from the database.
protected virtual Task DeleteDataInternalAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
- See Also
DeleteObject()
Deletes the object using appropriate provider.
protected override void DeleteObject()
EnsureData(bool, bool)
Creates a new data class container within the object
protected void EnsureData(bool loadDefault = true, bool applyTypeCondition = true)
Parameters
loadDefaultboolIf true, the process loads the default data
applyTypeConditionboolIf true, type condition is applied to the object
ExecuteWithOriginalData(Action)
Executes the given action using original data of the object.
public override void ExecuteWithOriginalData(Action action)
Parameters
actionActionAction to execute
Remarks
This operation temporarily modifies the object's state and is inherently not thread-safe
even when action is a read-only operation.
GetAutomaticProperty(string)
Tries to get the automatic property value for underlying object
protected object GetAutomaticProperty(string columnName)
Parameters
columnNamestringColumn name
Returns
- object
GetColumnNames()
Gets the default list of column names for this class
protected override List<string> GetColumnNames()
Returns
- List<string>
GetGeneralizedInfo()
Gets the generalized info for this object
protected override GeneralizedInfo GetGeneralizedInfo()
Returns
GetLocalColumnNames()
Gets the list of local column names for particular object
protected virtual List<string> GetLocalColumnNames()
Returns
- List<string>
GetLocalProperties()
Gets the list of local properties for particular object
protected virtual List<string> GetLocalProperties()
Returns
- List<string>
GetOriginalValue(string)
Returns the original value of column.
public override object GetOriginalValue(string columnName)
Parameters
columnNamestringColumn name
Returns
- object
GetPropertyType(string)
Gets the type of the given property
protected override Type GetPropertyType(string propertyName)
Parameters
propertyNamestringProperty name
Returns
- Type
GetRegisteredProperties()
Gets list of registered properties.
protected override List<string> GetRegisteredProperties()
Returns
- List<string>
GetValue(string)
Gets the field value.
public override object GetValue(string columnName)
Parameters
columnNamestringColumn name
Returns
- object
GetValue<T>(string, T)
Gets the field value converted to a specified type.
public T GetValue<T>(string columnName, T defaultValue)
Parameters
columnNamestringColumn name
defaultValueTDefault value to use if the value is empty or not convertible to a specified type
Returns
- T
Type Parameters
T
InsertData()
Inserts the object to the database.
protected virtual void InsertData()
InsertDataAsync(CancellationToken)
Asynchronously inserts the object to the database.
protected virtual Task InsertDataAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
InsertDataInternal()
Inserts the object data to the database.
protected virtual void InsertDataInternal()
- See Also
InsertDataInternalAsync(CancellationToken)
Asynchronously inserts the object data to the database.
protected virtual Task InsertDataInternalAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
- See Also
ItemChanged(string)
Returns true if the item on specified column name changed.
public override bool ItemChanged(string columnName)
Parameters
columnNamestringColumn name
Returns
- bool
LoadData(LoadDataSettings)
Loads the object using the given settings
protected override void LoadData(LoadDataSettings settings)
Parameters
settingsLoadDataSettingsData settings
LoadDefaultData()
Loads the default data to the object.
protected virtual void LoadDefaultData()
MakeComplete(bool)
Makes the object data complete.
public override void MakeComplete(bool loadFromDb)
Parameters
loadFromDbboolIf true, the data to complete the object is loaded from database
NewInternal(string)
Creates a new object of the given object type
protected static TInfo NewInternal(string objectType = null)
Parameters
objectTypestringObject type
Returns
- TInfo
RegisterProperties()
Registers the properties of this object
protected virtual void RegisterProperties()
RegisterProperty(string, Func<TInfo, object>)
Registers the given property to the object
protected PropertySettings<TInfo> RegisterProperty(string propertyName, Func<TInfo, object> ex)
Parameters
propertyNamestringProperty name
exFunc<TInfo, object>Lambda expression
Returns
- PropertySettings<TInfo>
RegisterProperty(string, object, Func<TInfo, object, object>)
Registers the given parametrized property to the object.
protected PropertySettings<TInfo> RegisterProperty(string propertyName, object parameter, Func<TInfo, object, object> ex)
Parameters
propertyNamestringProperty name
parameterobjectParameter for the lambda expression
exFunc<TInfo, object, object>Lambda expression
Returns
- PropertySettings<TInfo>
RegisterProperty<TProperty>(string, Func<TInfo, object>)
Registers the given property to the object
protected PropertySettings<TInfo> RegisterProperty<TProperty>(string propertyName, Func<TInfo, object> ex)
Parameters
propertyNamestringProperty name
exFunc<TInfo, object>Lambda expression
Returns
- PropertySettings<TInfo>
Type Parameters
TProperty
ReplaceWith<TNewInfo>()
Initiates the system to replace the info type with a specified type that must inherit from the original info type
public static IConditionalObjectFactory ReplaceWith<TNewInfo>() where TNewInfo : TInfo, new()
Returns
Type Parameters
TNewInfo
ResetChanges()
Resets the object changes and keeps the new values as unchanged according to the asUnchanged parameter.
public override void ResetChanges()
RevertChanges()
Reverts the object changes to the original values.
public override void RevertChanges()
SetData()
Updates or inserts the object to the database.
[Obsolete("Use InsertData(), UpdateData() or UpsertData() instead.")]
protected virtual void SetData()
SetDataAsync(CancellationToken)
Asynchronously updates or inserts the object to the database.
[Obsolete("Use InsertDataAsync(CancellationToken), UpdateDataAsync(CancellationToken) or UpsertDataAsync(CancellationToken) instead.")]
protected virtual Task SetDataAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
SetObject()
Updates the object using appropriate provider.
protected override void SetObject()
SetObjectOrderPostprocessing()
Method which is called after the order of the object was changed.
protected override void SetObjectOrderPostprocessing()
SetReadOnly()
Locks the object as a read-only
protected override void SetReadOnly()
SetValue(string, object)
Sets the field value.
public override bool SetValue(string columnName, object value)
Parameters
columnNamestringColumn name
valueobjectNew value
Returns
- bool
TouchKeys()
Touches the cache dependency keys of the object to flush the dependent cache items.
public void TouchKeys()
TryGetAutomaticProperty(string, ref object)
Tries to get the automatic property value for underlying object
protected bool TryGetAutomaticProperty(string columnName, ref object value)
Parameters
columnNamestringColumn name
valueobjectReturning value
Returns
- bool
TryGetProperty(string, out object)
Returns value of property.
public override bool TryGetProperty(string columnName, out object value)
Parameters
columnNamestringColumn name
valueobjectReturns the value
Returns
- bool
Returns true if the operation was successful (the value was present)
TryGetValue(string, out object)
Returns value of column.
public override bool TryGetValue(string columnName, out object value)
Parameters
columnNamestringColumn name
valueobjectReturns the value
Returns
- bool
Returns true if the operation was successful (the value was present)
UpdateData()
Updates the object in the database.
protected virtual void UpdateData()
UpdateDataAsync(CancellationToken)
Asynchronously updates the object in the database.
protected virtual Task UpdateDataAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
UpdateDataInternal()
Updates the object data in the database.
protected virtual void UpdateDataInternal()
- See Also
UpdateDataInternalAsync(CancellationToken)
Asynchronously updates the object data in the database.
protected virtual Task UpdateDataInternalAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
- See Also
UpsertData()
Updates or inserts the object to the database.
protected virtual void UpsertData()
UpsertDataAsync(CancellationToken)
Asynchronously updates or inserts the object to the database.
protected virtual Task UpsertDataAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
UpsertDataInternal(WhereCondition)
Upserts the data to the database.
protected virtual void UpsertDataInternal(WhereCondition existingWhere)
Parameters
existingWhereWhereConditionWhere condition targeting existing data for the upsert.
- See Also
UpsertDataInternalAsync(WhereCondition, CancellationToken)
Asynchronously upserts the data to the database.
protected virtual Task UpsertDataInternalAsync(WhereCondition existingWhere, CancellationToken cancellationToken)
Parameters
existingWhereWhereConditionWhere condition targeting existing data for the upsert.
cancellationTokenCancellationTokenThe cancellation instruction.
Returns
- Task
- See Also
Validate()
Validates whether the info object's state satisfies domain specific constraints and returns the validation result.
protected override InfoValidationResult Validate()
Returns
- InfoValidationResult
Returns validation result with IsValid set to true, if value is valid. Otherwise returns result with the flag set to false and a corresponding error message.
Remarks
The default implementation always returns Success. Override the method to perform domain specific info object validation.