FieldAttribute class

Namespace: CodeEffects.Rule.Attributes
Assembly: CodeEffects.Rule.dll

If applied to a public non-static value type property or field of the source object (qualified property), references it as a rule field.

Syntax

[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field,
	AllowMultiple = false, Inherited = true)]
public sealed class FieldAttribute : System.Attribute,
	CodeEffects.Rule.Attributes.IDescribableAttribute

Properties

  • AllowCalculations Type: System.Bool

    Used only in rule fields of numeric type. Ignored in fields of other types. Gets or sets the value indicating whether the value element of this field should be allowed to be expressed as a calculation. If set to True, rule authors must select between input and calculation input types before assigning the field's value. This property is optional. The default value is True.

  • CollectionItemName Type: System.String

    Used only in rule fields of collection type, and ignored in fields of other types. Gets or sets the display name of a collection in the rule. Please see the collection support topic for examples and details. This property is optional. The default value is the declared name of the property.

  • CollectionItemType Type: System.Type

    Used only in rule fields of non-generic collection type whose underlying type cannot be determined at run-time (qualified collection). This property is ignored in fields of other types and generic collections. Gets or sets the underlying type of a qualified collection. An example of a qualified collection would be the System.Collections.Specialized.StringCollection or System.Collections.ArrayList. This property is optional. The qualified collection is ignored if the value of this property is not set.

  • DataSourceName Type: System.String

    Used only in rule fields that represent the source object's properties of System.Int type, and ignored in fields of other types. Gets or sets the unique name of the Dynamic Menu Data Source declared by the SourceAttribute on the source object.

  • DateTimeFormat Type: System.String

    Used only in rule fields of date and time types, and ignored in fields of other types. Gets or sets the date or time format of the field's value displayed in the Rule Editor. You can use standard .NET date and time formatting. This property is not used during rule evaluation. This property is optional. The default value for date fields is "MMM dd, yyyy", and for time fields is "hh:mm tt".

  • Description Type: System.String

    Gets or sets the description of the rule field. Rule authors can see this description when they hover the mouse over the field element in the Rule Editor. The value of this property is ignored if RuleEditor.ShowDescriptionsOnMouseHover is set to False. It's not advisable to use this property in multilingual applications; instead use culture-specific custom Source XML documents. This property is optional.

  • DisplayName Type: System.String

    Gets or sets the display name of the rule field in the Rule Editor. Use this property to "represent" rule fields if the property name is not descriptive enough for non-technical rule authors. It's not advisable to use this property in multilingual applications; instead use culture-specific custom Source XML documents. This property is optional. The default value is the declared name of the property.

  • IncludeInCalculations Type: System.Bool

    Used only in rule fields of numeric type, and ignored in fields of other types. Gets or sets the value indicating whether the rule field can be included in value calculations of other fields. For example, it can be distracting to rule authors when a non-financial numeric field ID shows up in a calculation menu among financial fields like Income, Debt, and so on. In such cases, set the IncludeInCalculations to False. This property is optional. The default value is True.

  • Max Type: System.Int64

    Used only with numeric and string value elements, and ignored by other types. For numeric elements, gets or sets the maximum value of the field that rule authors can enter manually. For string elements, gets or sets the maximum length of the string that rule authors can type as the value. Used by Code Effects only in the UI, it's not used in rule evaluations. This property is optional.

  • Min Type: System.Int64

    Used only in rule fields of numeric type, and ignored in fields of other types. Gets or sets the minimum value of the field that rule authors can enter manually. Used by Code Effects only in the UI, it's not used in rule evaluations. This property is optional.

  • Settable Type: System.Bool

    Gets or sets the value indicating whether the value of the rule field can be set in execution type rules. In general, Code Effects component recognizes the readonly fields and properties with private setters; it won't allow the rule authors to set values of those fields and properties. Setting this value to False prevents the rule authors from setting values of any field or property using the rule editor. The default value is True.

  • StringComparison Type: System.StringComparison

    Used only in rule fields of string types, and ignored by other types. Gets or sets the string comparison option value that will be used to compare string values in rule conditions during evaluation. Can be used to set culture-specific comparison options, including case sensitivity. The default value is System.StringComparison.OrdinalIgnoreCase.

    IMPORTANT! This property is ignored by the rule-based data filtering feature. Use SqlServer's collation to set the string comparison behavior of all selects when using Code Effects with T-SQL LINQ providers such as Entity Framework.

  • ValueInputType Type: CodeEffects.Rule.Common.ValueInputType

    Gets or sets the value indicating whether the field's value can only be typed in manually, or it only accepts fields as a value, or both. For example, consider the rule condition FirstName = "John". In this condition, the value is "John", which is a string that the rule author typed in. This is a value entered by the "user", i.e. it's of type ValueInputType.User. The same condition can be expressed as FirstName = MiddleName. Since MiddleName is a field, this value was selected by the rule author as a "field" item from the menu, i.e. it's of type ValueInputType.Fields. This property is optional. The default value is ValueInputType.All, which allows both the User and the Fields input types.

Notes

This attribute is optional.

Example

using System;
using CodeEffects.Rule.Attributes;
using CodeEffects.Rule.Common;

namespace TestLibrary
{
	public class Person
	{
		[Field(ValueInputType = ValueInputType.User, Min = 1,
			IncludeInCalculations = false, AllowCalculations = false)]
		public int ID { get; set; }

		[Field(ValueInputType = ValueInputType.User, Max = 30)]
		public string Name { get; set; }

		[Field(ValueInputType = ValueInputType.User, Max = 11,
			DisplayName = "Social security number")]
		public string SSN { get; set; }

		[Field(DateTimeFormat = "MM/dd/yyyy", DisplayName = "Date of birth")]
		public DateTime DOB { get; set; }

		[Field(DateTimeFormat = "hh:mm:ss tt", DisplayName = "Time of birth")]
		public TimeSpan? TOB { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Total debt")]
		public decimal? Debt { get; set; }

		[Field(Min = 0, Max = 1000000, DisplayName = "Monthly income")]
		public decimal Income { get; set; }

		[Field(ValueInputType = ValueInputType.User)]
		public bool Married { get; set; }

		[Field(ValueInputType = ValueInputType.User)]
		public Gender Gender { get; set; }
	}

	public enum Gender
	{
		Male,
		Female,
		[ExcludeFromEvaluation]
		Unknown
	}
}
Post your support requests on Stackoverflow.com. You can also post your comments and product feedback using the form at the bottom of this page.
Comments: 0
Name (optional):
Comment (URLs are allowed and must start with http:// or https://; all tags will be encoded):
Remaining character count: