Show / Hide Table of Contents

Class ObservableObject

A simple lightweight base implementation for INotifyPropertyChanged and IDataErrorInfo

Inheritance
object
ObservableObject
ChangeTrackingObject
SoftwareUpdate
HierarchicalComposableTreeViewItem
Implements
INotifyPropertyChanged
IDataErrorInfo
INotifyDataErrorInfo
INotifyDataPropertyChanged
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
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
bool

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
bool
Exceptions
Type Condition
ArgumentNullException

Thrown when error is null.

ArgumentException

Thrown when error is a PropertyError.

View Source

CascadeErrors()

Cascades errors from property values that implement INotifyDataErrorInfo.

Declaration
protected IDisposable CascadeErrors()
Returns
Type Description
IDisposable

An IDisposable that ends cascading when it's 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
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
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
string propertyName

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

Returns
Type Description
IEnumerable<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
string propertyName

The name of the property.

See Also
NoDataAttribute
View Source

OnErrorsChanged(string)

Raise a ErrorsChanged event for the specified property.

Declaration
protected virtual void OnErrorsChanged(string propertyName)
Parameters
Type Name Description
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
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
string propertyName

The name of the property to validate.

Returns
Type Description
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
bool

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

Exceptions
Type Condition
ArgumentNullException

error was null.

View Source

RemoveError(Guid)

Removes the specified entity level error.

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

The id of the error to remove.

Returns
Type Description
bool

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 IEqualityComparer<T>. This will trigger a validation raise PropertyChanged if field and value are not equal.

Declaration
protected void SetValue<T>(string propertyName, ref T field, T value)
Parameters
Type Name Description
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 IEqualityComparer<T>. This will trigger a validation raise 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
string propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

Action<T> beforeChange

An action executed before the field is set.

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 IEqualityComparer<T>. This will trigger a validation raise 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
string propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

Action<T> beforeChange

An action executed before the field is set.

Action<T> afterChange

An action executed after the field is set.

IEqualityComparer<T> comparer

The 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 IEqualityComparer<T>. This will trigger a validation raise 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
string propertyName

The name of the property being changed.

T field

The field which should hold the property value.

T value

The new value.

IEqualityComparer<T> comparer

The 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

Occurs when a property value changes.

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
PropertyChangedEventHandler

Implements

INotifyPropertyChanged
IDataErrorInfo
INotifyDataErrorInfo
INotifyDataPropertyChanged

Extension Methods

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