Collection Class
Assembly: CodeEffects.Rule.Editor.dll
Namespace: CodeEffects.Rule.Editor.Client
Summary
Provides a way to specify collection-related settings for Fields, Parameters, and Return values of collection types in Adaptive Source.
This class is intended exclusively for use with the Adaptive Source model.
Syntax
public class Collection
Constructors
Properties
Type
Type: CodeEffects.Rule.Common.Models.CollectionType
The kind of the collection's underlying type: Value for value types and strings, Reference for reference types, Generic for a collection whose underlying type is not specified. The default value is CollectionType.None.
IsArray
Type: System.Boolean
Indicates whether the collection is an array. The default value is false.
IsGeneric
Type: System.Boolean
Indicates whether the collection is a generic type, such as List<T>. The default value is false.
CollectionSingleItemDisplayName
Type: System.String
The singular display name of the collection's underlying type, such as "School" for a collection of schools. The Rule Editor uses it in the collection's conditions. It is used only for collections of reference types.
CollectionSignleItemDisplayName
Type: System.String
Deprecated. This property, misspelled in earlier versions, will be removed in a future version. Use CollectionSingleItemDisplayName instead. It gets and sets the same value.
ComparisonName
Type: System.String
The generic type definition name of the collection. The Rule Editor uses this value to determine whether the collection can be compared with other collections defined in the Source, hence the name of this property. You can obtain this value from the type of your collection field, parameter, or return value by executing the following code:
Type constructed = typeof(ICollection<MyType>);
var name = constructed.GetGenericTypeDefinition().FullName; // "System.Collections.Generic.ICollection`1"
ElementTypeOrAliasName
Type: System.String
The full name or alias of the collection's underlying type. This property is ignored for generic collections.
Example
using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Editor.Client;
// Field of List<Student> type (reference-typed collection)
var field = new Field
{
Value = "Student.Schools",
DisplayName = "List of schools attended by the student",
DataType = DataType.Collection,
Collection = new Collection
{
ComparisonName = "System.Collections.Generic.List`1",
DataType = DataType.None, // No data types in reference collections
IsArray = false,
IsGeneric = true,
CollectionSingleItemDisplayName = "School",
IsElementTypeNullable = true,
Type = CollectionType.Reference,
ElementTypeOrAliasName = "TestProject.People.Student"
}
};
DataType
Type: CodeEffects.Rule.Common.Models.DataType
The data type of the collection's underlying type. Use this value only in value-typed collections (Type is CollectionType.Value). The default value is DataType.None.
Example
using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Editor.Client;
// Field of List<string> type (value-typed collection)
var field = new Field
{
Value = "Student.Nicknames",
DisplayName = "List of nicknames of the student",
DataType = DataType.Collection,
Collection = new Collection
{
ComparisonName = "System.Collections.Generic.List`1",
DataType = DataType.String,
IsArray = false,
IsGeneric = true,
IsElementTypeNullable = true,
Type = CollectionType.Value,
ElementTypeOrAliasName = "System.String"
}
};
IsElementTypeNullable
Type: System.Boolean
Indicates whether the collection's underlying type is nullable. A collection of int? is a collection of nullable elements, while a collection of int is not. The default value is true. A collection parameter accepts a collection argument only when both have the same value here.