Skip to content

Class BinaryCondition

Definition

Namespace: StardewUI.Framework.Binding
Assembly: StardewUI.dll

A condition based on the comparison of two values.

public class BinaryCondition : StardewUI.Framework.Binding.ICondition, 
    System.IDisposable

Inheritance
Object ⇦ BinaryCondition

Implements
ICondition, IDisposable

Remarks

Passes whenever both values are equal. Used for *switch and *case attributes.

Any type may be used for either operand, but a conversion must be available from one of the types to the other type in order for the condition to ever pass. If the two types are different, and conversion both ways is possible, then priority will be given to the type implementing IEquatable<T> on itself; if the best type is still ambiguous, then left->right conversion will be chosen over right->left.

Members

Constructors

Name Description
BinaryCondition(IValueSourceFactory, IValueConverterFactory, IResolutionScope, IAttribute, IResolutionScope, IAttribute) A condition based on the comparison of two values.

Properties

Name Description
LeftContext The context used to derive the LHS value, if the left attribute is a context binding.
LeftContextSelector Optional source for automatically updating the LeftContext.
Passed Whether or not the condition was passing as of the last Update().
RightContext The context used to derive the RHS value, if the right attribute is a context binding.
RightContextSelector Optional source for automatically updating the RightContext.

Methods

Name Description
Dispose()
Update() Re-evaluates the condition and updates the Passed state.

Details

Constructors

BinaryCondition(IValueSourceFactory, IValueConverterFactory, IResolutionScope, IAttribute, IResolutionScope, IAttribute)

A condition based on the comparison of two values.

public BinaryCondition(StardewUI.Framework.Sources.IValueSourceFactory valueSourceFactory, StardewUI.Framework.Converters.IValueConverterFactory valueConverterFactory, StardewUI.Framework.Content.IResolutionScope leftScope, StardewUI.Framework.Dom.IAttribute leftAttribute, StardewUI.Framework.Content.IResolutionScope rightScope, StardewUI.Framework.Dom.IAttribute rightAttribute);
Parameters

valueSourceFactory   IValueSourceFactory
The factory responsible for creating IValueSource<T> instances from attribute data.

valueConverterFactory   IValueConverterFactory
The factory responsible for creating IValueConverter<TSource, TDestination> instances, used to convert bound values to the types required by the target view.

leftScope   IResolutionScope
Scope for resolving any externalized leftAttribute values, such as translation keys.

leftAttribute   IAttribute
The attribute containing the expression for the LHS operand.

rightScope   IResolutionScope
Scope for resolving any externalized rightAttribute values, such as translation keys.

rightAttribute   IAttribute
The attribute containing the expression for the RHS operand.

Remarks

Passes whenever both values are equal. Used for *switch and *case attributes.

Any type may be used for either operand, but a conversion must be available from one of the types to the other type in order for the condition to ever pass. If the two types are different, and conversion both ways is possible, then priority will be given to the type implementing IEquatable<T> on itself; if the best type is still ambiguous, then left->right conversion will be chosen over right->left.


Properties

LeftContext

The context used to derive the LHS value, if the left attribute is a context binding.

public StardewUI.Framework.Binding.BindingContext LeftContext { get; set; }
Property Value

BindingContext


LeftContextSelector

Optional source for automatically updating the LeftContext.

public Func<StardewUI.Framework.Binding.BindingContext> LeftContextSelector { get; set; }
Property Value

Func<BindingContext>

Remarks

If specified, then this selector will be automatically run on every Update() and assigned to the LeftContext; otherwise, the LeftContext must be set explicitly in order to change the evaluation context for the left-hand value.


Passed

Whether or not the condition was passing as of the last Update().

public bool Passed { get; }
Property Value

Boolean


RightContext

The context used to derive the RHS value, if the right attribute is a context binding.

public StardewUI.Framework.Binding.BindingContext RightContext { get; set; }
Property Value

BindingContext


RightContextSelector

Optional source for automatically updating the RightContext.

public Func<StardewUI.Framework.Binding.BindingContext> RightContextSelector { get; set; }
Property Value

Func<BindingContext>

Remarks

If specified, then this selector will be automatically run on every Update() and assigned to the RightContext; otherwise, the RightContext must be set explicitly in order to change the evaluation context for the right-hand value.


Methods

Dispose()

public void Dispose();

Update()

Re-evaluates the condition and updates the Passed state.

public void Update();