Show / Hide Table of Contents

Class ObservableObject

A simple lightweight base implementation for System.ComponentModel.INotifyPropertyChanged and System.ComponentModel.IDataErrorInfo

Inheritance
System.Object
ObservableObject
ChangeTrackingObject
SoftwareUpdate
HierarchicalComposableTreeViewItem
Implements
System.ComponentModel.INotifyPropertyChanged
System.ComponentModel.IDataErrorInfo
System.ComponentModel.INotifyDataErrorInfo
INotifyDataPropertyChanged
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Infrastructure
Assembly: Sartorius.SAF.dll
Syntax
public abstract class ObservableObject : INotifyPropertyChanged, IDataErrorInfo, INotifyDataErrorInfo, INotifyDataPropertyChanged

Constructors

View Source

ObservableObject()

Initializes a new instance of the ObservableObject class.

Declaration
protected ObservableObject()

Properties

View Source

HasErrors

Gets a value indicating whether this entity has validation errors.

Declaration
protected bool HasErrors { get; }
Property Value
Type Description
System.Boolean

true if the entity currently has validation errors; otherwise false.

Methods

View Source

AddError(IError)

Adds the specified entity level error.

Declaration
protected bool AddError(IError error)
Parameters
Type Name Description
IError error

The entity level error.

Returns
Type Description
System.Boolean
Exceptions
Type Condition
System.ArgumentNullException

Thrown when error is null.

System.ArgumentException

Thrown when error is a PropertyError.

View Source

CascadeErrors()

Cascades errors from property values that implement System.ComponentModel.INotifyDataErrorInfo.

Declaration
protected IDisposable CascadeErrors()
Returns
Type Description
System.IDisposable

An System.IDisposable that ends cascading when it's System.IDisposable.Dispose() method is called.

View Source

ClearErrors()

Clears all errors.

Declaration
protected void ClearErrors()
View Source

ForceValidation<T>(String, T)

Forces the validation for the specified property.

Declaration
protected void ForceValidation<T>(string propertyName, T value)
Parameters
Type Name Description
System.String propertyName

The name of the property being changed.

T value

The new value.

Type Parameters
Name Description
T

The type of the property value.

View Source

GetEntityErrors()

Gets the current entity level errors.

Declaration
protected virtual IEnumerable<IError> GetEntityErrors()
Returns
Type Description
System.Collections.Generic.IEnumerable<IError>

An enumerable of all entity level errors.

View Source

GetErrors(String)

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

Declaration
protected virtual IEnumerable<string> GetErrors(string propertyName)
Parameters
Type Name Description
System.String propertyName

The name of the property to retrieve validation errors for; or null or System.String.Empty, to retrieve entity-level errors.

Returns
Type Description
System.Collections.Generic.IEnumerable<System.String>

The validation errors for a specified property or the entire entity.

View Source

OnDataPropertyChanged(String)

Called when a data property is changed.

Declaration
protected virtual void OnDataPropertyChanged(string propertyName)
Parameters
Type Name Description
System.String propertyName

The name of the property.

See Also
NoDataAttribute
View Source

OnErrorsChanged(String)

Raise a System.ComponentModel.INotifyDataErrorInfo.ErrorsChanged event for the specified property.

Declaration
protected virtual void OnErrorsChanged(string propertyName)
Parameters
Type Name Description
System.String propertyName

The name of the property that has it's error state changed.

View Source

OnPropertyChanged(String)

Raise a PropertyChanged event for the given property name.

Declaration
protected virtual void OnPropertyChanged(string propertyName)
Parameters
Type Name Description
System.String propertyName

The name of the property that has changed.

View Source

OnValidate(String)

Called when a property is changed and needs validation.

Declaration
protected virtual string OnValidate(string propertyName)
Parameters
Type Name Description
System.String propertyName

The name of the property to validate.

Returns
Type Description
System.String

The description of the error if the property fails validation; null otherwise.

View Source

RemoveError(IError)

Removes the specified entity level error.

Declaration
protected bool RemoveError(IError error)
Parameters
Type Name Description
IError error

The entity level error.

Returns
Type Description
System.Boolean

true if an error with the Id was found and removed; false otherwise.

Exceptions
Type Condition
System.ArgumentNullException

error was null.

View Source

RemoveError(Guid)

Removes the specified entity level error.

Declaration
protected bool RemoveError(Guid id)
Parameters
Type Name Description
System.Guid id

The id of the error to remove.

Returns
Type Description
System.Boolean

true if an error with the id was found and removed; false otherwise.

View Source

SetValue<T>(String, ref T, T)

Sets the given value if it is different to the given field using the provided System.Collections.Generic.IEqualityComparer<T>. This will trigger a validation raise System.ComponentModel.INotifyPropertyChanged.PropertyChanged if field and value are not equal.

Declaration
protected void SetValue<T>(string propertyName, ref T field, T value)
Parameters
Type Name Description
System.String propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

Type Parameters
Name Description
T

The type of the property value.

View Source

SetValue<T>(String, ref T, T, Action<T>, Action<T>)

Sets the given value if it is different to the given field using the provided System.Collections.Generic.IEqualityComparer<T>. This will trigger a validation raise System.ComponentModel.INotifyPropertyChanged.PropertyChanged if field and value are not equal.

Declaration
protected void SetValue<T>(string propertyName, ref T field, T value, Action<T> beforeChange, Action<T> afterChange)
Parameters
Type Name Description
System.String propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

System.Action<T> beforeChange

An action executed before the field is set.

System.Action<T> afterChange

An action executed after the field is set.

Type Parameters
Name Description
T

The type of the property value.

View Source

SetValue<T>(String, ref T, T, Action<T>, Action<T>, IEqualityComparer<T>)

Sets the given value if it is different to the given field using the provided System.Collections.Generic.IEqualityComparer<T>. This will trigger a validation raise System.ComponentModel.INotifyPropertyChanged.PropertyChanged if field and value are not equal.

Declaration
protected virtual void SetValue<T>(string propertyName, ref T field, T value, Action<T> beforeChange, Action<T> afterChange, IEqualityComparer<T> comparer)
Parameters
Type Name Description
System.String propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

System.Action<T> beforeChange

An action executed before the field is set.

System.Action<T> afterChange

An action executed after the field is set.

System.Collections.Generic.IEqualityComparer<T> comparer

The System.Collections.Generic.IEqualityComparer<T> used to compare the field and the new value.

Type Parameters
Name Description
T

The type of the property value.

View Source

SetValue<T>(String, ref T, T, IEqualityComparer<T>)

Sets the given value if it is different to the given field using the provided System.Collections.Generic.IEqualityComparer<T>. This will trigger a validation raise System.ComponentModel.INotifyPropertyChanged.PropertyChanged if field and value are not equal.

Declaration
protected void SetValue<T>(string propertyName, ref T field, T value, IEqualityComparer<T> comparer)
Parameters
Type Name Description
System.String propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

System.Collections.Generic.IEqualityComparer<T> comparer

The System.Collections.Generic.IEqualityComparer<T> used to compare the field and the new value.

Type Parameters
Name Description
T

The type of the property value.

Events

View Source

PropertyChanged

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
System.ComponentModel.PropertyChangedEventHandler

Explicit Interface Implementations

View Source

INotifyDataPropertyChanged.DataPropertyChanged

Declaration
event EventHandler<PropertyChangedEventArgs> INotifyDataPropertyChanged.DataPropertyChanged
Returns
Type Description
System.EventHandler<System.ComponentModel.PropertyChangedEventArgs>
View Source

IDataErrorInfo.Error

Declaration
string IDataErrorInfo.Error { get; }
Returns
Type Description
System.String
View Source

IDataErrorInfo.Item[String]

Declaration
string IDataErrorInfo.this[string columnName] { get; }
Parameters
Type Name Description
System.String columnName
Returns
Type Description
System.String
View Source

INotifyDataErrorInfo.ErrorsChanged

Declaration
event EventHandler<DataErrorsChangedEventArgs> INotifyDataErrorInfo.ErrorsChanged
Returns
Type Description
System.EventHandler<System.ComponentModel.DataErrorsChangedEventArgs>
View Source

INotifyDataErrorInfo.GetErrors(String)

Declaration
IEnumerable INotifyDataErrorInfo.GetErrors(string propertyName)
Parameters
Type Name Description
System.String propertyName
Returns
Type Description
System.Collections.IEnumerable
View Source

INotifyDataErrorInfo.HasErrors

Declaration
bool INotifyDataErrorInfo.HasErrors { get; }
Returns
Type Description
System.Boolean

Implements

System.ComponentModel.INotifyPropertyChanged
System.ComponentModel.IDataErrorInfo
System.ComponentModel.INotifyDataErrorInfo
INotifyDataPropertyChanged

Extension Methods

CollectionExtensions.AddRange<T, TCollection>(TCollection, IEnumerable<T>)
NotifyPropertyChangedExtensions.GetPropertyName<T>(INotifyPropertyChanged, Expression<Func<T>>)
NotifyPropertyChangedExtensions.RaisePropertyChanged<T>(INotifyPropertyChanged, Expression<Func<T>>)
NotifyPropertyChangedExtensions.RaisePropertyChanged(INotifyPropertyChanged, String)
PropertyHelper.RaisePropertyChanged<T>(INotifyPropertyChanged, Expression<Func<T>>, PropertyChangedEventHandler)
SerializableObjectCloneExtension.Clone<T>(T)
  • View Source
Back to top Generated by DocFX