Class EntityObject
Represents an instance of a Model
Implements
Inherited Members
Namespace: TimeCockpit.Data
Assembly: TimeCockpit.Data.dll
Syntax
public class EntityObject : DynamicObject, IDynamicMetaObjectProvider, INotifyPropertyChanged, IEntityObject, IComparable
Constructors
EntityObject()
Initializes a new instance of the Entity
Declaration
public EntityObject()
Properties
CreationVersion
Gets the creation version of the Entity
Declaration
public ulong CreationVersion { get; }
Property Value
Type | Description |
---|---|
System. |
Entity
Gets or sets the Model
Declaration
public ModelEntityBase Entity { get; protected set; }
Property Value
Type | Description |
---|---|
Model |
IsChanged
Gets a value indicating whether the object was changed.
See also On
Declaration
public bool IsChanged { get; }
Property Value
Type | Description |
---|---|
System. |
IsCloned
Gets a value indicating whether this instance is cloned.
Declaration
public bool IsCloned { get; }
Property Value
Type | Description |
---|---|
System. |
IsDeleted
Gets a value indicating whether the object was deleted.
See also On
Declaration
public bool IsDeleted { get; }
Property Value
Type | Description |
---|---|
System. |
IsNew
Gets a value indicating whether the object is new.
See also On
Declaration
public bool IsNew { get; }
Property Value
Type | Description |
---|---|
System. |
IsReadOnly
Gets a value indicating whether an Entity
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System. |
Remarks
If the Model
Item[String]
Gets the value of a specified member
Declaration
public object this[string propertyName] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System. |
propertyName | The name of the member to get the value for. |
Property Value
Type | Description |
---|---|
System. |
Returns the value of the specified member. |
Remarks
Internally, this indexer calls Get
LastUpdateVersion
Gets the update version of the Entity
Declaration
public ulong LastUpdateVersion { get; }
Property Value
Type | Description |
---|---|
System. |
LocalizedPropertyValues
Gets the localized property values.
Declaration
public LocalizedTextPropertyCollection LocalizedPropertyValues { get; }
Property Value
Type | Description |
---|---|
Localized |
Me
Gets the it self
Declaration
public EntityObject Me { get; }
Property Value
Type | Description |
---|---|
Entity |
Remarks
This property is needed for DataBinding reasons.
Whenever a property of an Entity
ModelEntityName
Gets the name of the current instance of Entity
Declaration
public string ModelEntityName { get; }
Property Value
Type | Description |
---|---|
System. |
Implements
ObjectUuid
Gets the unique id of the object.
Declaration
public Guid ObjectUuid { get; }
Property Value
Type | Description |
---|---|
System. |
Implements
Permission
Gets the permissions of an Entity
Declaration
public PermissionType Permission { get; }
Property Value
Type | Description |
---|---|
Permission |
RelationIdentifiers
Gets the relation identifiers for the EntityObject
Declaration
public RelationIdentifiers RelationIdentifiers { get; }
Property Value
Type | Description |
---|---|
Relation |
States
Gets a dictionary of property states for an object.
Declaration
protected MemberStatus[] States { get; }
Property Value
Type | Description |
---|---|
Member |
Values
Gets a dictionary of values for an object.
Declaration
protected object[] Values { get; }
Property Value
Type | Description |
---|---|
System. |
Methods
CalculateMember(String)
Evaluates a formla, applies it to this Entity
Declaration
public object CalculateMember(string formula)
Parameters
Type | Name | Description |
---|---|---|
System. |
formula | Formla to evaluate |
Returns
Type | Description |
---|---|
System. |
Result of the formula |
Exceptions
Type | Condition |
---|---|
System. |
might throw a NullReferenceException. |
See Also
Clone()
Makes a deep clone an Entity
Declaration
public EntityObject Clone()
Returns
Type | Description |
---|---|
Entity |
A cloned entity object |
Clone(Boolean)
Makes a deep clone an Entity
Declaration
public EntityObject Clone(bool deepClone)
Parameters
Type | Name | Description |
---|---|---|
System. |
deepClone | if set to |
Returns
Type | Description |
---|---|
Entity |
A cloned entity object |
Clone(Boolean, Boolean)
Makes a deep clone an Entity
Declaration
public EntityObject Clone(bool deepClone, bool resetMembersInReadonlyExpression)
Parameters
Type | Name | Description |
---|---|---|
System. |
deepClone | if set to |
System. |
resetMembersInReadonlyExpression | if set to |
Returns
Type | Description |
---|---|
Entity |
A cloned entity object |
Clone(Boolean, Boolean, Environment)
Makes a deep clone an Entity
Declaration
public EntityObject Clone(bool deepClone, bool resetMembersInReadonlyExpression, Environment environment)
Parameters
Type | Name | Description |
---|---|---|
System. |
deepClone | if set to |
System. |
resetMembersInReadonlyExpression | if set to |
Environment | environment | An instance of environment to perform permission validation. |
Returns
Type | Description |
---|---|
Entity |
A cloned entity object |
Clone(ModelEntityBase)
Makes a deep clone of an Entity
Declaration
public EntityObject Clone(ModelEntityBase entity)
Parameters
Type | Name | Description |
---|---|---|
Model |
entity | The Model |
Returns
Type | Description |
---|---|
Entity |
A cloned instance of an Entity |
CompareTo(Object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
System. |
obj | An object to compare with this instance. |
Returns
Type | Description |
---|---|
System. |
A value that indicates the relative order of the objects being compared. |
Implements
CopyTo(EntityObject)
Copies the values of an instance of an Entity
Declaration
public void CopyTo(EntityObject target)
Parameters
Type | Name | Description |
---|---|---|
Entity |
target | The target Entity |
Deserialize(String, EntityObject, Model)
Deserializes an Entity
Declaration
public static EntityObject Deserialize(string data, EntityObject parentEntity, Model model)
Parameters
Type | Name | Description |
---|---|---|
System. |
data | An instance of Entity |
Entity |
parentEntity | The parent Entity |
Model | model | An instance of Model to fetch type information about the Entity |
Returns
Type | Description |
---|---|
Entity |
An instance of Entity |
Deserialize(XElement, EntityObject, Model)
Deserializes an Entity
Declaration
public static EntityObject Deserialize(XElement root, EntityObject parentEntity, Model model)
Parameters
Type | Name | Description |
---|---|---|
System. |
root | System. |
Entity |
parentEntity | The parent Entity |
Model | model | An instance of Model |
Returns
Type | Description |
---|---|
Entity |
The deserialized instance of Entity |
Remarks
For Entity
Exceptions
Type | Condition |
---|---|
Unknown |
If the propertyEncoding attribute is present in the XML to deserialize and it is set
to another value than 'Base64' this method throws a Unknown |
Evaluate<T>(String)
Evaluates the specified expression and returns a compiled function
Declaration
public T Evaluate<T>(string expression)
Parameters
Type | Name | Description |
---|---|---|
System. |
expression | The expression that should be compiled. |
Returns
Type | Description |
---|---|
T | The result of the expression when applied to the instance of the Entity |
Type Parameters
Name | Description |
---|---|
T | The datatype the result of the expression should be casted to |
Evaluate<T>(String, Environment, IEnumerable<QueryParameter>)
Evaluates the specified expression and returns a compiled function
Declaration
public T Evaluate<T>(string expression, Environment environment, IEnumerable<QueryParameter> parameters = null)
Parameters
Type | Name | Description |
---|---|---|
System. |
expression | The expression that should be compiled. |
Environment | environment | An instance of Environment that has to be supplied, if the expression referenes Environment variables |
System. |
parameters | The parameters that are passed to the expression. |
Returns
Type | Description |
---|---|
T | The result of the expression when applied to the instance of the Entity |
Type Parameters
Name | Description |
---|---|
T | The datatype the result of the expression should be casted to |
GetActualMember(String)
Gets the actual value of the specified member.
Declaration
public virtual object GetActualMember(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Name of the member. |
Returns
Type | Description |
---|---|
System. |
Returns the actual value of the specified member. The default implementation
of this method calls Get |
GetChangedMembers()
Gets a list of member names that have the status Changed
Declaration
public IEnumerable<string> GetChangedMembers()
Returns
Type | Description |
---|---|
System. |
A list of member name that have the status Changed |
GetMember(Int32)
Gets the value of the specified member.
Declaration
public object GetMember(int index)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | Index of the member. |
Returns
Type | Description |
---|---|
System. |
Returns the value of the specified member. |
GetMember(String)
Gets the value of the specified member.
Declaration
public override object GetMember(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Name of the member. |
Returns
Type | Description |
---|---|
System. |
Returns the value of the specified member. |
Overrides
Remarks
This method also returns the clr properties '{ModelEntityName}Uuid' and 'IsReadOnly' of an Entity
GetMembersByState(MemberStatus)
Gets a list of member names that have the requested state.
Declaration
public IEnumerable<string> GetMembersByState(MemberStatus state)
Parameters
Type | Name | Description |
---|---|---|
Member |
state | Reqested state. |
Returns
Type | Description |
---|---|
System. |
A list of member name that have the requested state. |
GetMetaObject(Expression)
Gets the meta object of the dynamic object.
Declaration
public override DynamicMetaObject GetMetaObject(Expression parameter)
Parameters
Type | Name | Description |
---|---|---|
System. |
parameter | Provided by the DLR (Dynamic Language Runtime). |
Returns
Type | Description |
---|---|
System. |
System. |
Overrides
GetPropertyIndex(String)
Gets ContentMap index for a name.
Declaration
protected virtual int GetPropertyIndex(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Name of the property to get ContentMap index for. |
Returns
Type | Description |
---|---|
System. |
The ContentMap index of the Prooperty. Value is -1 if property does not exists in ContentMap |
GetValidationMessages(NameLocalizer)
Gets the validation messages.
Declaration
public IEnumerable<ValidationMessage> GetValidationMessages(NameLocalizer localizer)
Parameters
Type | Name | Description |
---|---|---|
Name |
localizer | The localizer to use for localizing validation rules. |
Returns
Type | Description |
---|---|
System. |
Iterates the validation messages. |
HasPermission(String, PermissionType)
Checks if a user has a permission of a certain type.
Declaration
public bool HasPermission(string memberName, PermissionType permissionType)
Parameters
Type | Name | Description |
---|---|---|
System. |
memberName | The name of the property to check for permission. |
Permission |
permissionType | The type of the permission (see also Permission |
Returns
Type | Description |
---|---|
System. |
True, if the property has the same permission as permissionIdentifier, else false. |
MarkAsDeleted()
Marks the object as deleted.
Declaration
public void MarkAsDeleted()
MarkAsNew(Boolean)
Marks an entity object as new
Declaration
public void MarkAsNew(bool resetMemberStates = true)
Parameters
Type | Name | Description |
---|---|---|
System. |
resetMemberStates | Indicates whether the member states and IssChanged should be adjusted. |
OnPropertyChanged(Int32, Object, Object)
Invoked whenever the value of any property on this object has been updated. The specific property that changed is reported in the event data.
Declaration
protected virtual void OnPropertyChanged(int index, object previousValue, object currentValue)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | Index of the property that has been updated. |
System. |
previousValue | the previous value of the property. |
System. |
currentValue | the currentValue of the property. |
Remarks
This method sets a property in the Values collection of an Entity
OnPropertyChanged(String, Object, Object)
Invoked whenever the value of any property on this object has been updated. The specific property that changed is reported in the event data.
Declaration
protected virtual void OnPropertyChanged(string propertyName, object previousValue, object currentValue)
Parameters
Type | Name | Description |
---|---|---|
System. |
propertyName | Name of the property that has been updated. |
System. |
previousValue | the previous value of the property. |
System. |
currentValue | the current value of the property. |
Remarks
This method sets a property in the Values collection of an Entity
Serialize()
Serializes an Entity
Declaration
public XmlReader Serialize()
Returns
Type | Description |
---|---|
System. |
An instance of an System. |
Serialize(Boolean)
Serializes an Entity
Declaration
public XmlReader Serialize(bool idsOnly)
Parameters
Type | Name | Description |
---|---|---|
System. |
idsOnly | Determines whether to serialize the whole entity object in case of a relation or just the identifier or the relation. |
Returns
Type | Description |
---|---|
System. |
An instance of an System. |
Remarks
If the Entity
This method serializes an Entity
This method serializes properties of a Entity
Serialize(XmlWriter, Boolean)
Writes the XML representation of an Entity
Declaration
public void Serialize(XmlWriter xmlWriter, bool idsOnly)
Parameters
Type | Name | Description |
---|---|---|
System. |
xmlWriter | The System. |
System. |
idsOnly | Determines whether to serialize the whole Entity |
Remarks
If the Entity
This method serializes an Entity
This method serializes properties of a Entity
SetMember(Int32, Object)
Sets a dynamic member.
Declaration
public void SetMember(int index, object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
index | Index of the member to set. |
System. |
value | Value to set. |
SetMember(String, Object)
Sets a dynamic member.
Declaration
public override void SetMember(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Name of the member to set. |
System. |
value | Value to set. |
Overrides
SetMember(String, Object, Boolean, Boolean)
Sets a dynamic member.
Declaration
public void SetMember(string name, object value, bool initialization, bool ignoreDefaultValues = false)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | Name of the member to set. |
System. |
value | Value to set. |
System. |
initialization | Indicates if SetMember is called during initialization of the object. |
System. |
ignoreDefaultValues | Indicates that no default values are set if this flag is set to true. Default is false |
ToString()
Returns a System.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System. |
A System. |
Overrides
Remarks
This methods returns the value of the default display property as string.
If the default display property happens to be a relation, it returns the value
of the default display property of the Entity
Validate(out List<String>, out List<ValidationRule>, NameLocalizer)
Validates all values (properties and relations) of an instance of an Entity
Declaration
public bool Validate(out List<string> errorMessages, out List<ValidationRule> failingValidationRules, NameLocalizer localizer)
Parameters
Type | Name | Description |
---|---|---|
System. |
errorMessages | The error messages provided by the failing Validation |
System. |
failingValidationRules | The Validation |
Name |
localizer | The Name |
Returns
Type | Description |
---|---|
System. |
True if the Entity |
Remarks
Internally, this method calls Validate(String, out String, out Validation
Validate(String, out String, out ValidationRule, NameLocalizer)
Validates a property of an instance of Entity
Declaration
public bool Validate(string name, out string message, out ValidationRule failingValidationRule, NameLocalizer localizer)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the property that is to be validated. |
System. |
message | An error message provided by the failing Validation |
Validation |
failingValidationRule | The Validation |
Name |
localizer | The Name |
Returns
Type | Description |
---|---|
System. |
True if the Entity |
Exceptions
Type | Condition |
---|---|
System. |
This method throws a System. |
Events
PropertyChanged
Occurs after the value of an application settings property is changed.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
System. |