Class AttributeBase<TStorage, TPresentation>
- Namespace
- The.Attributes
- Assembly
- Instagile.dll
Attribute which represents a datastore column, either set manually or calculated by supplied code.
[DataContract]
public abstract class AttributeBase<TStorage, TPresentation> : AttributeBase, IProperty, IOwned, IHasChanges, IComparable, IComparable<AttributeBase<TStorage, TPresentation>>
Type Parameters
TStorageTPresentation
- Inheritance
-
AttributeBase<TStorage, TPresentation>
- Implements
-
IComparable<AttributeBase<TStorage, TPresentation>>
- Derived
- Inherited Members
Remarks
basically this class has a mode matrix, four modes for each combo of IsCalculated and IsTransient - it is at the root of an inheritance hierarchy :( a cool refactoring would be to split out the part which depends on properties into a composed part with multiple implementations. however, i made an attempt at this and it seemed to increase rather than reduce complexity
Properties
DynamicTypeDefault
public override sealed object? DynamicTypeDefault { get; }
Property Value
DynamicValue
public override object? DynamicValue { get; set; }
Property Value
IsDefaulted
public bool IsDefaulted { get; set; }
Property Value
OriginalValue
public TStorage OriginalValue { get; }
Property Value
- TStorage
PersistenceValue
protected virtual TStorage PersistenceValue { get; set; }
Property Value
- TStorage
Value
[DataMember]
public abstract TPresentation Value { get; set; }
Property Value
- TPresentation
ValueType
public override Type ValueType { get; }
Property Value
Methods
CalculateAsync()
public override Task CalculateAsync()
Returns
Compare(TStorage, TStorage)
protected abstract int Compare(TStorage left, TStorage right)
Parameters
leftTStoragerightTStorage
Returns
CompareNullable<U>(U?, U?, Func<U, U, int>)
public static int CompareNullable<U>(U? left, U? right, Func<U, U, int> compare) where U : struct
Parameters
Returns
Type Parameters
U
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.
public override int CompareTo(object? other)
Parameters
otherobject
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes objin the sort order.Zero This instance occurs in the same position in the sort order as obj.Greater than zero This instance follows objin the sort order.
Exceptions
- ArgumentException
objis not the same type as this instance.
CompareTo(AttributeBase<TStorage, TPresentation>?)
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.
public int CompareTo(AttributeBase<TStorage, TPresentation>? other)
Parameters
otherAttributeBase<TStorage, TPresentation>An object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes otherin the sort order.Zero This instance occurs in the same position in the sort order as other.Greater than zero This instance follows otherin the sort order.
HasChanges()
true if the current value differs from its original
public override bool HasChanges()
Returns
InternalCopy(AttributeBase, AttributeBase)
protected override void InternalCopy(AttributeBase from, AttributeBase to)
Parameters
fromAttributeBasetoAttributeBase
MarkUnchanged()
update original data so that it's no longer considered changed
public override void MarkUnchanged()
Normalise(TStorage?, bool)
protected virtual TStorage Normalise(TStorage? newValue, bool isCalculated)
Parameters
newValueTStorageisCalculatedbool
Returns
- TStorage
RaiseOrDeferValueChanged()
protected void RaiseOrDeferValueChanged()
TypeDefault()
public abstract TStorage TypeDefault()
Returns
- TStorage