Class Model
- Namespace
- TimeCockpit.Data.DataModel
- Assembly
- TimeCockpit.Data.dll
Represents a Time Cockpit metadata model
public sealed class Model : ModelElement, IDynamicMetaObjectProvider, INotifyPropertyChanged, IDataErrorInfo, ISupportInitialize
- Inheritance
-
ObjectModel
- Implements
-
IDynamicMetaObjectProviderINotifyPropertyChangedIDataErrorInfoISupportInitialize
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Constructors
Model()
Initializes a new instance of the Model class.
public Model()
Model(Model)
Initializes a new instance of the Model class.
public Model(Model element)
Parameters
elementModelThe element to copy.
Remarks
Copy constructor for copying values of an instance of Model. The constructor copies all the values of the value types, but creates new instances of all ModelEntitys by calling their copy constructor. ModelActions, EntityViews, NamedSetDefinitions and Permissions of the Model to copy are just added to the corresponding collections.
Properties
Actions
Gets the collection used to store all available model actions of a model.
public ModelCollection<ModelAction> Actions { get; }
Property Value
ApplicationSpecificEntities
Gets the application specific entities of the current model.
public IEnumerable<ModelEntityBase> ApplicationSpecificEntities { get; }
Property Value
- IEnumerable<ModelEntityBase>
Cultures
Gets the cultures supported by the current instance of Model.
public ModelCollection<Culture> Cultures { get; }
Property Value
- ModelCollection<Culture>
The cultures.
Entities
Gets the collection used to store the entities of the data model.
public ModelCollection<ModelEntityBase> Entities { get; }
Property Value
EntityViews
Gets the collection used to store all available entity views in a model.
public ModelCollection<EntityView> EntityViews { get; }
Property Value
IsFrozen
Gets a value indicating whether the model is frozen
public bool IsFrozen { get; }
Property Value
- Boolean
Remarks
Frozen models always have TrackChanges = false. You cannot change a frozen model so that it tracks changes.
- See Also
LocalModelVersion
Gets the local version number of this model
public int LocalModelVersion { get; }
Property Value
- Int32
Remarks
The local model version is an internal version counter for the model. Whenever a model change is written to disk the local model version is incremented. Note that this property is not incremented as long as changes have not been written to disk using SaveModel(Model).
ModelEntityViews
Gets the collection used to store all available entity views in a model.
[Obsolete("Use EntityViews instead")]
public ModelCollection<EntityView> ModelEntityViews { get; }
Property Value
NamedSetDefinitions
Gets the collection used to store named set definitions in a model.
public ModelCollection<NamedSetDefinition> NamedSetDefinitions { get; }
Property Value
Permissions
Gets the collection used to store allowed permissions.
public ModelCollection<Permission> Permissions { get; }
Property Value
SkipEntityMemberNameValidation
Gets or sets a value indicating whether the check for member name equals entity name in model validation should be skipped.
public static bool SkipEntityMemberNameValidation { get; set; }
Property Value
- Boolean
Remarks
Use with caution! The validation check that can be disabled by this property is required for proper OData/EDM compatibility. For COFX applications that do not require OData/EDM this flag may be set to true.
SystemEntities
Gets the collection used to store the system entities of the data model.
public IEnumerable<ModelEntityBase> SystemEntities { get; }
Property Value
- IEnumerable<ModelEntityBase>
TrackChanges
Gets a value indicating whether the model is currently tracking changes.
public bool TrackChanges { get; }
Property Value
- Boolean
Remarks
If TrackChanges is true changes to the model and it's child
objects are collected. You can save all changes to a model using the
SaveModel(Model) method.
If TrackChanges is false changes to the model and it's child
objects are not collected. As a result you cannot save changes to the underlying data
store.
UserEntities
Gets the user entities of the current model.
public IEnumerable<ModelEntityBase> UserEntities { get; }
Property Value
- IEnumerable<ModelEntityBase>
Methods
Accept(ModelElementVisitor)
Accepts a visitor. Dispatches the correct visit call (for Model)in the visitor.
public override void Accept(ModelElementVisitor visitor)
Parameters
visitorModelElementVisitorthe visitor to dispatch to.
Attach(ModelElement)
Attaches a model to a parent model element.
protected override void Attach(ModelElement newParent)
Parameters
newParentModelElementParent model element.
Exceptions
- System.InvalidOperationException
Always thrown because a model cannot be attached to a parent model element.
Freeze()
Freezes the model
public void Freeze()
- See Also
GetDefaultCulture()
Gets the default culture.
public Culture GetDefaultCulture()
Returns
GetDesiredCultureOrDefault(CultureInfo)
Tries to find the culture the current thread is using in the model cultures.
public Culture GetDesiredCultureOrDefault(CultureInfo desiredCulture)
Parameters
desiredCultureCultureInfoThe desired culture.
Returns
- Culture
The desired culture or a fallback culture.
Remarks
Example: If the current thread culture is de-AT and de-AT is a registered culture in the model the method returns de-AT. If de-AT is not registered in the model, the method checks if the parent culture of the culture of the current thread (in this example de) is registered in the model and if so, returns it. If the parent thread culture is not registered either, the default culture is returned
GetMember(String)
Gets a member dynamically.
public override object GetMember(string name)
Parameters
nameStringName of the member to get.
Returns
- Object
Dynamic member.
GetMetaObject(Expression)
Gets the meta object of the dynamic object.
public override DynamicMetaObject GetMetaObject(Expression parameter)
Parameters
parameterExpressionProvided by the DLR (Dynamic Language Runtime).
Returns
- DynamicMetaObject
DynamicObject.DynamicMetaObject that represents this specific object’s binding logic.
GetModelElementByUuid(Guid)
Gets one of the following model elements according to its guid entities, properties, validation rules, model entity interface
public ModelElement GetModelElementByUuid(Guid guid)
Parameters
guidGuidthe guid to search for
Returns
- ModelElement
The model element with the given id or null if there is not element with this id.
HasCultures()
Determines whether this instance of a model has cultures.
public bool HasCultures()
Returns
- Boolean
True if the model contains cultues, else false
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 part of the internal infrastructure of the TimeCockpit.Data and must not
be called from outside.
SetDefaultCulture(Culture)
Sets the default culture.
public void SetDefaultCulture(Culture proposedDefaultCulture)
Parameters
proposedDefaultCultureCultureThe proposed default culture.
Exceptions
- System.ArgumentException
Thrown if the proposed culture cannot be found in the model.
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.