Class ModelProperty
- Namespace
- TimeCockpit.Data.DataModel
- Assembly
- TimeCockpit.Data.dll
Represents a property in the Time Cockpit data model.
public abstract class ModelProperty : ModelElement, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo, INullable
- Inheritance
-
ObjectModelProperty
- Implements
-
IDynamicMetaObjectProviderINotifyPropertyChangedIDataErrorInfo
- Derived
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Constructors
ModelProperty()
Initializes a new instance of the ModelProperty class.
protected ModelProperty()
ModelProperty(IEnumerable<KeyValuePair<Object, Object>>)
Initializes a new instance of the ModelProperty class.
protected ModelProperty(IEnumerable<KeyValuePair<object, object>> properties)
Parameters
propertiesIEnumerable<KeyValuePair<Object, Object>>Collection of properties.
ModelProperty(ModelProperty)
Initializes a new instance of the ModelProperty class.
protected ModelProperty(ModelProperty element)
Parameters
elementModelPropertyThe element to copy.
Properties
ClrDefaultValue
Gets the default value for the .NET type of the property.
public abstract object ClrDefaultValue { get; }
Property Value
- Object
DataType
Gets the .NET type of the property.
public abstract Type DataType { get; }
Property Value
- Type
DefaultAggregateFunction
Gets or sets the default aggregate function.
public DefaultAggregateFunction DefaultAggregateFunction { get; set; }
Property Value
- DefaultAggregateFunction
The default aggregate function.
DefaultValue
Gets the default value for a .NET.
public object DefaultValue { get; }
Property Value
- Object
DefaultValueExpression
Gets or sets the expression that determines the default value of the property
public string DefaultValueExpression { get; set; }
Property Value
- String
DefaultValueFunction
Gets the default value of a property by evaluate an expression
public Func<EntityObject, Environment, IEnumerable<QueryParameter>, object> DefaultValueFunction { get; }
Property Value
- Func<EntityObject, Environment, IEnumerable<QueryParameter>, Object>
EvaluateDefaultValue
Gets a value indicating whether to evaluate the default value.
public bool EvaluateDefaultValue { get; }
Property Value
- Boolean
trueif the default value is to be evaluate; otherwise,false.
EvaluateDefaultValueExpression
Gets or sets the default value evaluation time expression.
public string EvaluateDefaultValueExpression { get; set; }
Property Value
- String
The default value evaluation time expression.
EvaluateDefaultValueFunction
Gets a value determining whether a default value should be evaluated
public Func<EntityObject, bool> EvaluateDefaultValueFunction { get; }
Property Value
- Func<EntityObject, Boolean>
HasDefaultValueExpression
Gets a value indicating whether a property has a default value expression or not
public bool HasDefaultValueExpression { get; }
Property Value
- Boolean
InvariantFriendlyTypeName
Gets the friendly type name of a model property
public string InvariantFriendlyTypeName { get; }
Property Value
- String
IsDefaultDisplayProperty
Gets or sets a value indicating whether the ModelProperty is the default display property of a ModelEntity
public bool IsDefaultDisplayProperty { get; set; }
Property Value
- Boolean
IsNullable
Gets or sets a value indicating whether the ModelProperty instance should be nullable or not.
public bool IsNullable { get; set; }
Property Value
- Boolean
Permissions
Gets the deny read write permissions of the ModelProperty.
public ModelCollection<Permission> Permissions { get; }
Property Value
Methods
Accept(ModelElementVisitor)
Accepts a visitor. Dispatches the visit handler for a ModelProperty. Note that more specific implementations of ModelProperty (e.g. TextProperty, NumericProperty, etc.) will use a different visitor (to be defined) approach, as this may need to be extensible.
public override void Accept(ModelElementVisitor visitor)
Parameters
visitorModelElementVisitorthe visitor to dispatch.
Attach(ModelElement)
Attaches a model element to a parent model element.
protected override void Attach(ModelElement newParent)
Parameters
newParentModelElementParent model element.
Remarks
Note to implementers: If your model element has sub-elements, your implementation of Attach
should call the base class' implementation and afterwards attach all sub-elements.
Exceptions
- System.ArgumentNullException
newParentis null.- System.ArgumentException
Thrown in case of a recursion in the model element tree.
Convert(Object)
Converts an object to the type of the property.
public abstract object Convert(object value)
Parameters
valueObjectObject to convert.
Returns
- Object
Returns the converted object.
GetHumanReadableMemberPath()
Gets the human readable member path (includes parent entity name except for filter entities).
protected string GetHumanReadableMemberPath()
Returns
- String
Human readable member path.
IsValueAffectedByPropertyChange(EntityObject, String)
Determines whether the value for this property is changed if the memberName is changed.
public bool IsValueAffectedByPropertyChange(EntityObject entityObject, string memberName)
Parameters
entityObjectEntityObjectThe entityobject holding the property that changed.
memberNameStringThe name of the member (relation or property) that changed.
Returns
- Boolean
Returns a value indicating whether the value of a property is affected by a changed property name.
OnDeserializing(StreamingContext)
Called whenever deserialization of the model element is happening
[OnDeserializing]
public void OnDeserializing(StreamingContext context)
Parameters
contextStreamingContextStream context used for deserialization.
Remarks
This method is necessary to instantiate an instance of the current ModelElement after deserialization. As for the System.Runtime.Serialization.DataContractSerializer, constructors are not always called and fields not correctly initialized. While deserializing, this method is called and the fields of the ModelElement are correctly initialized.
ShallowCopy()
Performs a shallow copy of the current ModelProperty.
public ModelProperty ShallowCopy()
Returns
- ModelProperty
A shallow copy of the current ModelProperty.
Remarks
The MemberwiseClone method creates a shallow copy by creating a new object, and then copying the nonstatic fields of the current object to the new object. If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.
ShallowCopy(String, PersistBehavior, Ownership, Boolean, Boolean)
Performs a shallow copy of the current ModelProperty.
public ModelProperty ShallowCopy(string name, PersistBehavior persistBehavior, Ownership ownership, bool ignorePermissions = false, bool ignoreDefaultValues = false)
Parameters
nameStringThe name of the property to clone.
persistBehaviorPersistBehaviorThe PersistBehavior the cloned property should have.
ownershipOwnershipThe Ownership the cloned property should have.
ignorePermissionsBooleanif set to
true[ignore permissions].ignoreDefaultValuesBooleanif set to
true[ignore default values].
Returns
- ModelProperty
A shallow copy of the current ModelProperty.
Remarks
The MemberwiseClone method creates a shallow copy by creating a new object, and then copying the nonstatic fields of the current object to the new object. If a field is a value type, a bit-by-bit copy of the field is performed. If a field is a reference type, the reference is copied but the referred object is not; therefore, the original object and its clone refer to the same object.
Validate(ref IList<PropertyValidationMessage>, Boolean)
Validates a ModelElement according to certain rules.
protected override void Validate(ref IList<PropertyValidationMessage> messages, bool validateRecursively)
Parameters
messagesIList<PropertyValidationMessage>An list of strings that stores that picks up the validation errors of a model element.
validateRecursivelyBooleanIndicates wheter to validate only the current model element or all its children (recursively) as well.
Remarks
The rules the ModelElement is validated against are dependent on the type of ModelElement that is validated. This method can be overridden to provide custom validation behavior for subclasses of ModelElement
When Validate(ref IList<PropertyValidationMessage>, Boolean) is called on a modelelement, the Validate(ref IList<PropertyValidationMessage>, Boolean) method of all children attatched to the modelelemnt are validated recursivly.
ValidateValue(Object, out String)
Validates whether the value is valid and provides an error message if not.
public abstract bool ValidateValue(object value, out string errorMessage)
Parameters
valueObjectThe value to validate.
errorMessageStringThe errorMessage, or null if it is valid.
Returns
- Boolean
Returns true if the value is valid, false otherwise.