Class Form
Represents a form composed of a set of Control objects. Controls are resolved from FormData via reflection and initialized asynchronously.
Inherited Members
Namespace: DataWeb.Data
Assembly: DataWeb.Core.dll
Syntax
public sealed class Form
Constructors
Form(IReflectionService, IAppErrorService, IFormStore, IServiceProvider)
Represents a form composed of a set of Control objects. Controls are resolved from FormData via reflection and initialized asynchronously.
Declaration
public Form(IReflectionService reflectionService, IAppErrorService appErrorService, IFormStore formStore, IServiceProvider serviceProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| IReflectionService | reflectionService | The IReflectionService used to resolve control types by class name. |
| IAppErrorService | appErrorService | The IAppErrorService used to log control load errors. |
| IFormStore | formStore | The IFormStore used to load and cache form definitions. |
| IServiceProvider | serviceProvider | The IServiceProvider used to instantiate control objects. |
Properties
Controls
Gets or sets the list of controls that belong to the form.
Declaration
public List<Control> Controls { get; set; }
Property Value
| Type | Description |
|---|---|
| List<Control> |
IdMaster
Gets or sets the master identifier of the form definition in the data store.
Declaration
public string IdMaster { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Name
Gets or sets the name of the form.
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
InitAsync(FormData, CancellationToken)
Initializes the form directly from a FormData object, bypassing the data store.
Declaration
public Task InitAsync(FormData formData, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| FormData | formData | The FormData object that describes the form structure. |
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous initialization operation. |
InitAsync(string, string, CancellationToken)
Loads and initializes the form by name and optional culture. If culture is
omitted, the current thread culture is used. The form definition is retrieved from the cache via IFormStore.
Declaration
public Task InitAsync(string name, string culture = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the form to load. Must not be null or empty. |
| string | culture | The culture used to localize the form (e.g. |
| CancellationToken | cancellationToken | A token to monitor for cancellation requests. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous initialization operation. |
Exceptions
| Type | Condition |
|---|---|
| Exception | Thrown when |
IsUserControl(Control, IUser)
Determines whether control is accessible to user.
Returns true when the control has no role restriction, when the user holds at least one
of the allowed roles, or when the user is in the Developer role.
Declaration
public static bool IsUserControl(Control control, IUser user)
Parameters
| Type | Name | Description |
|---|---|---|
| Control | control | The Control to check. |
| IUser | user | The IUser whose roles are evaluated. |
Returns
| Type | Description |
|---|---|
| bool |
|
SetControlEvents(Control, ProvidedValue)
Evaluates all reactive events defined on control against the supplied providedValue
and immediately applies the resulting state changes (visibility, required) to the target controls in this form.
Declaration
public void SetControlEvents(Control control, Form.ProvidedValue providedValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Control | control | The Control whose events are evaluated. |
| Form.ProvidedValue | providedValue | The Form.ProvidedValue that triggered the event evaluation. |