Class BehaviorFactory
Definition
Namespace: StardewUI.Framework.Behaviors
Assembly: StardewUI.dll
A behavior factory based on per-name delegates. Can be used as a base class for other factories.
Inheritance
Object ⇦ BehaviorFactory
Implements
IBehaviorFactory
Members
Constructors
| Name | Description |
|---|---|
| BehaviorFactory() |
Methods
| Name | Description |
|---|---|
| Add(IBehaviorFactory) | Adds a new delegate factory which this factory will be allowed to use as a fallback for any behavior names not handled directly. |
| CanCreateBehavior(string, string) | Checks if the factory can create behaviors with a specified name and argument. |
| CreateBehavior(Type, string, string) | Creates a new behavior. |
| Register<TBehavior>(string) | Registers a behavior for a given name using the behavior's default parameterless constructor. |
| Register(string, Func<string, IViewBehavior>) | Registers a behavior for a given name using a delegate function. |
Details
Constructors
BehaviorFactory()
Methods
Add(IBehaviorFactory)
Adds a new delegate factory which this factory will be allowed to use as a fallback for any behavior names not handled directly.
Parameters
factory IBehaviorFactory
The delegate factory.
CanCreateBehavior(string, string)
Checks if the factory can create behaviors with a specified name and argument.
Parameters
name string
The behavior name.
argument string
The argument for the behavior, if any. Most implementations can ignore this parameter, but in some cases it is used for disambiguation.
Returns
true if this factory should handle the specified name, when given the specified argument, otherwise false.
CreateBehavior(Type, string, string)
Creates a new behavior.
public StardewUI.Framework.Behaviors.IViewBehavior CreateBehavior(System.Type viewType, string name, string argument);
Parameters
viewType Type
The specific type of IView that will receive the behavior.
name string
The behavior name that specifies the type of behavior.
argument string
Additional argument provided in the markup, distinct from the behavior's DataType. Enables prefixed behaviors such as tween:opacity
Returns
A new behavior of a type corresponding to the name.
Register<TBehavior>(string)
Registers a behavior for a given name using the behavior's default parameterless constructor.
Parameters
name string
The markup name used to create to the TBehavior type.
Remarks
Used for behaviors that do not take arguments, only data.
Register(string, Func<string, IViewBehavior>)
Registers a behavior for a given name using a delegate function.
public void Register(string name, Func<string, StardewUI.Framework.Behaviors.IViewBehavior> factory);
Parameters
name string
The markup name used to create this type of behavior.
factory Func<string, IViewBehavior>
Delegate function that accepts the construction argument (if any) and creates the corresponding behavior.