TX Text Control .NET Server

Condition Class

Class|Introduced in 28.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK from the private NuGet feed or Text Control Offline Packages
Assembly
TXTextControl.Core.dll
Install
dotnet add package TXTextControl.TextControl.Core.SDK .NET 8 and later. For .NET Framework, reference TXTextControl.dll from the setup.
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll
Implements
IComparable

Description

An object of the Condition class is an element of the ConditionalInstruction class and represents the state of a FormField that has to be fulfilled to execute the instructions of the related ConditionalInstruction object. The number of conditions inside a ConditionalInstruction object is not limited. If the ConditionalInstruction.Conditions property contains more than one element, each subsequent Condition object is connected to the previous one by an AND or OR logical connective. That implies that all these conditions are considered as a whole when the conditional instruction is tested whether or not the requirements to execute its instructions are fulfilled.

To create a condition, the Condition object has to be initialized with a FormField that is located inside the document. That FormField provides the value to be tested.

Furthermore, a comparison value has to be defined by the constructor's comparisonValue parameter. That value is compared with the FormField's value by using a specified comparisonOperator parameter. The way in which such a comparison is implemented depends on how the set value is interpreted:

• The constructor's isChecked parameter value of a condition that references to a CheckFormField represents a check state to be fulfilled. If it is set to true, the Condition.ComparisonOperator property returns Condition.ComparisonOperators.Is. Otherwise Condition.ComparisonOperators.IsNot. In both cases the Condition.ComparisonValue property returns true.

• Conditions that are related to form fields of type TextFormField or SelectionFormField execute a comparison to the form field's Text property value. That text can be tested as follows: If the comparison value is set to null or an emtpy string, the condition checks whether or not any text is set. If it is a string, that is not empty, by default the value is interpreted as a custom text whose string is compared with form field's text. Alternatively, that string can be handled as a regular expression that checks whether or not the form field's text matches to its pattern. That option can be determined by setting the constructor's textComparisonFlag parameter to Condition.TextComparisonFlags.Regex.

• In addition, the text of a SelectionFormField object can be compared with one of its SelectionFormField.Items array entries or checked whether or not the string equals to one of its SelectionFormField.Items array entries. These comparison types can be determined by setting the corresponding Condition.ItemComparisonFlags enumeration value to the constructor's itemComparisonFlag parameter.

• Up to four different comparison types can be applied to compare the Date property of DateFormField objects with a specified value: If the comparison value is an object of type System.DateTime, the year, month and day of month is compared with the current property value. On setting an integer with an value between 1601 and 9999, the year is compared. If that value is an integer between 1 and 31, the day of the month is checked. An enumeration value of type Condition.Month tests the month and using a System.DayOfWeek enumeration value compares the day of the week. Setting null as the comparison value checks whether or not the DateFormField.Date property value is set.

Syntax

public class Condition : IComparable

Examples

The following example builds a rule around an approval check box in a fillable form.

CheckFormField approvalField = new(false) { Name = "Approved" };
textControl.FormFields.Add(approvalField);
Condition condition = new(approvalField, true);

Members

Constructors

ConstructorDescription
ConditionInitializes a new instance of the Condition class.

Properties

PropertyDescription
ComparisonOperatorGets the operator that is used to compare the condition's form field value with the specified comparison value.
ComparisonValueGets the value that is compared with the condition's form field value.
ComparisonValueTypeGets a value of type ComparisonValueTypes that determines how the condition's comparison value is interpreted. The returned value depends on the type of the condition's FormField, the set comparison value and/or the textComparisonFlag or itemComparisonFlag parameter that were specified on invoking an instance of the Condition class.
FormFieldGets the FormField whose property value is to be compared with the condition's comparison value.
LogicalConnectiveGets or sets a value of type Condition.LogicalConnectives that describes how the condition is related to the previous condition inside the corresponding ConditionalInstruction.Conditions array. If the condition is the first element of that array, the value of that property is ignored. The default value is LogicalConnectives.And.

Methods

MethodDescription
CompareToNot described in the reference. public int CompareTo(object obj);

Enumerations

EnumerationDescription
ComparisonOperatorsDetermines the comparison operator that is used to compare the condition's form field value with the specified comparison value or the interpretation of that value. The enumeration contains the following values:
ComparisonValueTypesDetermines how the condition's comparison value is interpreted by the condition. The enumeration contains the following values:
ItemComparisonFlagsDetermines how the specified comparison value has to be interpreted when comparing it with the SelectionFormField's Text property. The enumeration contains the following values:
LogicalConnectivesDetermines how the condition is related to the previous condition inside the corresponding ConditionalInstruction.Conditions array. The enumeration contains the following values:
MonthDetermines the month that is compared with the condition's form field value. This enumeration can only be used as comparison value for form fields of type DateFormField. It contains the following values:
TextComparisonFlagsDetermines how the specified comparison value has to be interpreted when comparing it with the TextFormField's or SelectionFormField's Text property. The enumeration contains the following values: