C# Класс Catel.Data.ModelBase

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
IsDirtyProperty PropertyData
IsReadOnlyProperty PropertyData

Private Properties

Свойство Тип Описание
CatchUpWithSuspendedAnnotationsValidation void
ClearIsDirtyOnAllChilds void
EnsureValidationIsUpToDate void
FinishInitializationAfterConstructionOrDeserialization void
GetObjectData void
GetValidator IValidator
HandleObjectEventsSubscription void
IEditableObject void
IModelValidation void
INotifyDataErrorInfo IEnumerable
INotifyDataWarningInfo IEnumerable
IXmlSerializable XmlSchema
IXmlSerializable void
IXmlSerializable void
Initialize void
ModelBase System
NotifyErrorsChanged void
NotifyWarningsChanged void
OnDeserialized void
OnValidated void
OnValidatedBusinessRules void
OnValidatedFields void
OnValidating void
OnValidatingBusinessRules void
OnValidatingFields void
RaisePropertyChanged void
RaisePropertyChangedForAllRegisteredProperties void
SetBusinessRuleValidationResult void
SetFieldValidationResult void
ValidatePropertyUsingAnnotations bool
this stringIDataErrorInfo.Runtime.Serialization
this stringIDataWarningInfo.Runtime.Serialization

Открытые методы

Метод Описание
Equals ( object obj ) : bool

Determines whether the specified System.Object is equal to this instance.

GetHashCode ( ) : int

Returns a hash code for this instance.

SuspendChangeCallbacks ( ) : IDisposable

Suspends the change callbacks whenever a property has been called. This is very useful when there are expensive property change callbacks registered with a property that need to be temporarily disabled.

SuspendChangeNotifications ( bool raiseOnResume = true ) : IDisposable

Suspends the change notifications until the disposed object has been released.

SuspendValidations ( bool validateOnResume = true ) : IDisposable

Suspends the validation until the disposable token has been disposed.

ToString ( ) : string

Returns a System.String that represents this instance.

Validate ( bool force, bool validateDataAnnotations ) : void

Validates the current object for field and business rule errors.

To check whether this object contains any errors, use the INotifyDataErrorInfo.HasErrors property.

operator ( ) : bool

Implements the operator ==.

Защищенные методы

Метод Описание
ClearIsDirtyOnAllChilds ( ) : void

Clears the IsDirty on all childs.

GetBusinessRuleErrors ( ) : string

Gets the current errors errors.

GetBusinessRuleWarnings ( ) : string

Gets the current business warnings.

GetFieldErrors ( string columnName ) : string

Gets the errors for a specific column.

GetFieldWarnings ( string columnName ) : string

Gets the warnings for a specific column.

InitializeCustomProperties ( ) : void

Allows the initialization of custom properties. This is a virtual method that is called inside the constructor before the object is fully constructed. This might be considered as bad or as a hack, but it's a good way to be able to inject custom properties before any actual logic is handled by derived classes.

Only use when you really know what you are doing.

ModelBase ( SerializationInfo info, StreamingContext context ) : Catel.IoC

Initializes a new instance of the ModelBase class. Only constructor for the ModelBase.

Call this method, even when constructing the object for the first time (thus not deserializing).

NotifyValidationResult ( IValidationResult validationResult, bool notifyGlobal ) : void

Raises the right events based on the validation result.

OnBeginEdit ( System.ComponentModel.BeginEditEventArgs e ) : void

Raises the IEditableObject.BeginEdit event.

OnCancelEdit ( System.ComponentModel.EditEventArgs e ) : void

Raises the IEditableObject.CancelEdit event.

OnCancelEditCompleted ( System.ComponentModel.CancelEditCompletedEventArgs e ) : void

Raises the IAdvancedEditableObject.CancelEditingCompleted event.

OnEndEdit ( System.ComponentModel.EditEventArgs e ) : void

Raises the IEditableObject.EndEdit event.

OnInitialized ( ) : void

Called when the object is initialized.

OnInitializing ( ) : void

Called when the object is being initialized.

OnPropertyObjectCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void

Called when a property that implements INotifyCollectionChanged raises the event.

OnPropertyObjectCollectionItemPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when a property inside a collection that implements INotifyCollectionChanged that implements INotifyPropertyChanged raises the event.

OnPropertyObjectPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when a property that implements INotifyPropertyChanged raises the event.

OnValidated ( IValidationContext validationContext ) : void

Called when the object is validated.

OnValidatedBusinessRules ( IValidationContext validationContext ) : void

Called when the object has validated the business rules.

OnValidatedFields ( IValidationContext validationContext ) : void

Called when the object has validated the fields.

OnValidating ( IValidationContext validationContext ) : void

Called when the object is validating.

OnValidatingBusinessRules ( IValidationContext validationContext ) : void

Called when the object is validating the business rules.

OnValidatingFields ( IValidationContext validationContext ) : void

Called when the object is validating the fields.

RaisePropertyChanged ( object sender, Catel.Data.AdvancedPropertyChangedEventArgs e ) : void

Raises the INotifyPropertyChanged.PropertyChanged event.

This method is overriden en does not call the base because lots of additional logic is added in this class. The RaisePropertyChanged(object,System.ComponentModel.PropertyChangedEventArgs,bool,bool) will explicitly call ObservableObject.RaisePropertyChanged(object, AdvancedPropertyChangedEventArgs). If this method is overriden, it is very important to call the base.

SetDirtyAndAutomaticallyValidate ( string propertyName, bool setDirtyAndAllowAutomaticValidation ) : void

Sets the IsDirty property and automatically validate if required.

SetParent ( IParent parent ) : void

Sets the new parent of this object.

ShouldPropertyChangeUpdateIsDirty ( string propertyName ) : bool

Determines whether a specific property change should update IsDirty to true.

Validate ( bool force = false ) : void

Validates the current object for field and business rule errors.

To check whether this object contains any errors, use the INotifyDataErrorInfo.HasErrors property.

ValidateBusinessRules ( List validationResults ) : void

Validates the business rules of this object. Override this method to enable validation of business rules.

ValidateFields ( List validationResults ) : void

Validates the field values of this object. Override this method to enable validation of field values.

Приватные методы

Метод Описание
CatchUpWithSuspendedAnnotationsValidation ( ) : void

Catches up with suspended annotations validation. This method will take care of unvalidated properties that have been changed during the suspended validation state of this model.

ClearIsDirtyOnAllChilds ( object obj, HashSet handledReferences ) : void

Clears the IsDirty on all childs.

EnsureValidationIsUpToDate ( bool constraint = true ) : void

Ensures the validation is up to date.

FinishInitializationAfterConstructionOrDeserialization ( ) : void

Finishes the initialization after construction or deserialization.

GetObjectData ( SerializationInfo info, StreamingContext context ) : void
GetValidator ( ) : IValidator

Gets the validator. If the field is null, it will query the service locator.

HandleObjectEventsSubscription ( string propertyName, object propertyValue ) : void

Handles the object events subscription. This means that the old value will be removed from the event subscriptions, and the new value will be subscribed to.

IEditableObject ( ) : void

Begins an edit on an object.

IModelValidation ( bool force ) : void

Validates the current object for field and business rule errors.

To check whether this object contains any errors, use the INotifyDataErrorInfo.HasErrors property.

INotifyDataErrorInfo ( string propertyName ) : IEnumerable

Gets the validation errors for a specified property or for the entire object.

INotifyDataWarningInfo ( string propertyName ) : IEnumerable

Gets the warnings for the specific property name.

IXmlSerializable ( ) : XmlSchema

This method is reserved and should not be used. When implementing the IXmlSerializable interface, you should return null (Nothing in Visual Basic) from this method, and instead, if specifying a custom schema is required, apply the T:System.Xml.Serialization.XmlSchemaProviderAttribute to the class.

IXmlSerializable ( XmlReader reader ) : void

Generates an object from its XML representation.

IXmlSerializable ( XmlWriter writer ) : void

Converts an object into its XML representation.

Initialize ( ) : void

Initializes the object by setting default values.

ModelBase ( ) : System

Initializes static members of the ModelBase class.

NotifyErrorsChanged ( string propertyName, bool notifyHasErrors ) : void

Notifies all listeners that the errors for the specified property have changed. If the propertyName is null or string.Empty, the business errors will be updated.

NotifyWarningsChanged ( string propertyName, bool notifyHasWarnings ) : void

Notifies all listeners that the warnings for the specified property have changed. If the propertyName is null or string.Empty, the business errors will be updated.

OnDeserialized ( StreamingContext context ) : void
OnValidated ( ) : void
OnValidatedBusinessRules ( ) : void
OnValidatedFields ( ) : void
OnValidating ( ) : void
OnValidatingBusinessRules ( ) : void
OnValidatingFields ( ) : void
RaisePropertyChanged ( object sender, PropertyChangedEventArgs e, bool setDirtyAndAllowAutomaticValidation, bool isRefreshCallOnly ) : void

Invoked when a property value has changed.

RaisePropertyChangedForAllRegisteredProperties ( ) : void

Invokes the property changed for all registered properties.

Using this method does not set the IsDirty property to true, nor will it cause the object to validate itself automatically, even when the AutomaticallyValidateOnPropertyChanged is set to true.

SetBusinessRuleValidationResult ( IBusinessRuleValidationResult validationResult ) : void
SetFieldValidationResult ( IFieldValidationResult validationResult ) : void
ValidatePropertyUsingAnnotations ( string propertyName, object value, PropertyData catelPropertyData ) : bool

Validates the property using data annotations.

this ( string columnName ) : stringIDataErrorInfo.Runtime.Serialization

Gets an error for a specific column.

this ( string columnName ) : stringIDataWarningInfo.Runtime.Serialization

Gets a warning for a specific column.

Описание методов

ClearIsDirtyOnAllChilds() защищенный Метод

Clears the IsDirty on all childs.
protected ClearIsDirtyOnAllChilds ( ) : void
Результат void

Equals() публичный Метод

Determines whether the specified System.Object is equal to this instance.
/// The parameter is null. ///
public Equals ( object obj ) : bool
obj object The to compare with this instance.
Результат bool

GetBusinessRuleErrors() защищенный Метод

Gets the current errors errors.
protected GetBusinessRuleErrors ( ) : string
Результат string

GetBusinessRuleWarnings() защищенный Метод

Gets the current business warnings.
protected GetBusinessRuleWarnings ( ) : string
Результат string

GetFieldErrors() защищенный Метод

Gets the errors for a specific column.
protected GetFieldErrors ( string columnName ) : string
columnName string Column name.
Результат string

GetFieldWarnings() защищенный Метод

Gets the warnings for a specific column.
protected GetFieldWarnings ( string columnName ) : string
columnName string Column name.
Результат string

GetHashCode() публичный Метод

Returns a hash code for this instance.
public GetHashCode ( ) : int
Результат int

InitializeCustomProperties() защищенный Метод

Allows the initialization of custom properties. This is a virtual method that is called inside the constructor before the object is fully constructed. This might be considered as bad or as a hack, but it's a good way to be able to inject custom properties before any actual logic is handled by derived classes.
Only use when you really know what you are doing.
protected InitializeCustomProperties ( ) : void
Результат void

ModelBase() защищенный Метод

Initializes a new instance of the ModelBase class. Only constructor for the ModelBase.
Call this method, even when constructing the object for the first time (thus not deserializing).
protected ModelBase ( SerializationInfo info, StreamingContext context ) : Catel.IoC
info SerializationInfo SerializationInfo object, null if this is the first time construction.
context StreamingContext StreamingContext object, simple pass a default new StreamingContext() if this is the first time construction.
Результат Catel.IoC

NotifyValidationResult() защищенный Метод

Raises the right events based on the validation result.
The is null.
protected NotifyValidationResult ( IValidationResult validationResult, bool notifyGlobal ) : void
validationResult IValidationResult The validation result.
notifyGlobal bool If set to true, the global properties such as and are also raised.
Результат void

OnBeginEdit() защищенный Метод

Raises the IEditableObject.BeginEdit event.
protected OnBeginEdit ( System.ComponentModel.BeginEditEventArgs e ) : void
e System.ComponentModel.BeginEditEventArgs The instance containing the event data.
Результат void

OnCancelEdit() защищенный Метод

Raises the IEditableObject.CancelEdit event.
protected OnCancelEdit ( System.ComponentModel.EditEventArgs e ) : void
e System.ComponentModel.EditEventArgs The instance containing the event data.
Результат void

OnCancelEditCompleted() защищенный Метод

Raises the IAdvancedEditableObject.CancelEditingCompleted event.
protected OnCancelEditCompleted ( System.ComponentModel.CancelEditCompletedEventArgs e ) : void
e System.ComponentModel.CancelEditCompletedEventArgs The instance containing the event data.
Результат void

OnEndEdit() защищенный Метод

Raises the IEditableObject.EndEdit event.
protected OnEndEdit ( System.ComponentModel.EditEventArgs e ) : void
e System.ComponentModel.EditEventArgs The instance containing the event data.
Результат void

OnInitialized() защищенный Метод

Called when the object is initialized.
protected OnInitialized ( ) : void
Результат void

OnInitializing() защищенный Метод

Called when the object is being initialized.
protected OnInitializing ( ) : void
Результат void

OnPropertyObjectCollectionChanged() защищенный Метод

Called when a property that implements INotifyCollectionChanged raises the event.
protected OnPropertyObjectCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void
sender object The sender.
e NotifyCollectionChangedEventArgs The instance containing the event data.
Результат void

OnPropertyObjectCollectionItemPropertyChanged() защищенный Метод

Called when a property inside a collection that implements INotifyCollectionChanged that implements INotifyPropertyChanged raises the event.
protected OnPropertyObjectCollectionItemPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
Результат void

OnPropertyObjectPropertyChanged() защищенный Метод

Called when a property that implements INotifyPropertyChanged raises the event.
protected OnPropertyObjectPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
Результат void

OnValidated() защищенный Метод

Called when the object is validated.
protected OnValidated ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

OnValidatedBusinessRules() защищенный Метод

Called when the object has validated the business rules.
protected OnValidatedBusinessRules ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

OnValidatedFields() защищенный Метод

Called when the object has validated the fields.
protected OnValidatedFields ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

OnValidating() защищенный Метод

Called when the object is validating.
protected OnValidating ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

OnValidatingBusinessRules() защищенный Метод

Called when the object is validating the business rules.
protected OnValidatingBusinessRules ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

OnValidatingFields() защищенный Метод

Called when the object is validating the fields.
protected OnValidatingFields ( IValidationContext validationContext ) : void
validationContext IValidationContext The validation context.
Результат void

RaisePropertyChanged() защищенный Метод

Raises the INotifyPropertyChanged.PropertyChanged event.
This method is overriden en does not call the base because lots of additional logic is added in this class. The RaisePropertyChanged(object,System.ComponentModel.PropertyChangedEventArgs,bool,bool) will explicitly call ObservableObject.RaisePropertyChanged(object, AdvancedPropertyChangedEventArgs). If this method is overriden, it is very important to call the base.
protected RaisePropertyChanged ( object sender, Catel.Data.AdvancedPropertyChangedEventArgs e ) : void
sender object The sender.
e Catel.Data.AdvancedPropertyChangedEventArgs The instance containing the event data.
Результат void

SetDirtyAndAutomaticallyValidate() защищенный Метод

Sets the IsDirty property and automatically validate if required.
protected SetDirtyAndAutomaticallyValidate ( string propertyName, bool setDirtyAndAllowAutomaticValidation ) : void
propertyName string Name of the property.
setDirtyAndAllowAutomaticValidation bool If set to true, the property is set and automatic validation is allowed.
Результат void

SetParent() защищенный Метод

Sets the new parent of this object.
protected SetParent ( IParent parent ) : void
parent IParent The new parent.
Результат void

ShouldPropertyChangeUpdateIsDirty() защищенный Метод

Determines whether a specific property change should update IsDirty to true.
protected ShouldPropertyChangeUpdateIsDirty ( string propertyName ) : bool
propertyName string
Результат bool

SuspendChangeCallbacks() публичный Метод

Suspends the change callbacks whenever a property has been called. This is very useful when there are expensive property change callbacks registered with a property that need to be temporarily disabled.
public SuspendChangeCallbacks ( ) : IDisposable
Результат IDisposable

SuspendChangeNotifications() публичный Метод

Suspends the change notifications until the disposed object has been released.
public SuspendChangeNotifications ( bool raiseOnResume = true ) : IDisposable
raiseOnResume bool if set to true, the notifications are invoked on resume.
Результат IDisposable

SuspendValidations() публичный Метод

Suspends the validation until the disposable token has been disposed.
public SuspendValidations ( bool validateOnResume = true ) : IDisposable
validateOnResume bool
Результат IDisposable

ToString() публичный Метод

Returns a System.String that represents this instance.
public ToString ( ) : string
Результат string

Validate() защищенный Метод

Validates the current object for field and business rule errors.
To check whether this object contains any errors, use the INotifyDataErrorInfo.HasErrors property.
protected Validate ( bool force = false ) : void
force bool If set to true, a validation is forced. When the validation is not forced, it means /// that when the object is already validated, and no properties have been changed, no validation actually occurs /// since there is no reason for any values to have changed. ///
Результат void

Validate() публичный Метод

Validates the current object for field and business rule errors.
To check whether this object contains any errors, use the INotifyDataErrorInfo.HasErrors property.
public Validate ( bool force, bool validateDataAnnotations ) : void
force bool If set to true, a validation is forced (even if the object knows it is already validated).
validateDataAnnotations bool If set to true, the data annotations will be checked. This value is only used if is set to true.
Результат void

ValidateBusinessRules() защищенный Метод

Validates the business rules of this object. Override this method to enable validation of business rules.
protected ValidateBusinessRules ( List validationResults ) : void
validationResults List The validation results, add additional results to this list.
Результат void

ValidateFields() защищенный Метод

Validates the field values of this object. Override this method to enable validation of field values.
protected ValidateFields ( List validationResults ) : void
validationResults List The validation results, add additional results to this list.
Результат void

operator() публичный статический Метод

Implements the operator ==.
public static operator ( ) : bool
Результат bool

Описание свойств

IsDirtyProperty публичное статическое свойство

Register the IsDirty property so it is known in the class.
public static PropertyData IsDirtyProperty
Результат PropertyData

IsReadOnlyProperty публичное статическое свойство

Register the IsReadOnly property so it is known in the class.
public static PropertyData IsReadOnlyProperty
Результат PropertyData