Class FieldDefinition
Represents a custom field that can be associated with a translation memory or a fields template and for which values (FieldValue) can be associated with translation units in a translation memory (see FieldValues). These field values can subsequently be used in filter expressions (see FilterExpression) when searching or updating translation units.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemoryApi
Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
Syntax
public class FieldDefinition : IField
Constructors
FieldDefinition()
Creates a new empty field definition.
Declaration
public FieldDefinition()
Remarks
In order to add the new field to a translation memory or fields template, add it to the corresponding fields collection (FieldDefinitions or FieldDefinitions) and save the translation memory or fields template to persist the change (Save() or Save())
FieldDefinition(Field)
Declaration
public FieldDefinition(Field field)
Parameters
Type | Name | Description |
---|---|---|
Field | field |
FieldDefinition(Field, Boolean)
Initializes a new instance of the FieldDefinition class.
Declaration
[Obsolete("Please use FieldDefinition(Field field) constructor ")]
public FieldDefinition(Field field, bool isReadOnly)
Parameters
Type | Name | Description |
---|---|---|
Field | field | The field. |
System.Boolean | isReadOnly | if set to |
FieldDefinition(String, FieldValueType)
Creates a new field definition with the specified name and value type.
Declaration
public FieldDefinition(string name, FieldValueType valueType)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the field. |
FieldValueType | valueType | The type of value this field can hold. |
Remarks
In order to add the new field to a translation memory or fields template, add it to the corresponding fields collection (FieldDefinitions or FieldDefinitions) and save the translation memory or fields template to persist the change (Save() or Save())
FieldDefinition(String, FieldValueType, String[])
Creates a new picklist field definition with the specified name and value type.
Declaration
public FieldDefinition(string name, FieldValueType valueType, string[] picklistItems)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the field. |
FieldValueType | valueType | The type of value this field can hold. This has to be SinglePicklist or MultiplePicklist. |
System.String[] | picklistItems | An array of picklist values. |
Remarks
In order to add the new field to a translation memory or fields template, add it to the corresponding fields collection (FieldDefinitions or FieldDefinitions) and save the translation memory or fields template to persist the change (Save() or Save())
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if |
Fields
MaximumNameLength
The maximum length of a field name.
Declaration
public static readonly int MaximumNameLength
Field Value
Type | Description |
---|---|
System.Int32 |
MaximumTextFieldValueLength
The maximum length of a text field value.
Declaration
public static readonly int MaximumTextFieldValueLength
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
Id
Gets a unique Id for this field definition.
Declaration
public Guid Id { get; }
Property Value
Type | Description |
---|---|
System.Guid |
IsNewObject
Gets a value indicating whether this instance is new object.
Declaration
public bool IsNewObject { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsPicklist
Gets a value indicating whether this instance is picklist.
Declaration
public bool IsPicklist { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Name
Gets or sets the name of the field.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Note that you have to save the translation memory of the fields template to persist the change after setting this property, depending on whether the field belongs to a translation memory or a fields template.
PicklistItemNames
The names of all picklist items for this Field. This collection will be empty if this field is not a SinglePicklist or MultiplePicklist.
Declaration
public IList<string> PicklistItemNames { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<System.String> |
PicklistItems
Gets the picklist items representing the possible values for the field, in case this field is of type SinglePicklist or MultiplePicklist.
Declaration
public PicklistItemDefinitionCollection PicklistItems { get; }
Property Value
Type | Description |
---|---|
PicklistItemDefinitionCollection |
Remarks
Note that you have to save the translation memory of the fields template to persist the change after adding or removing picklist items, depending on whether the field belongs to a translation memory or a fields template.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Thrown when trying to access this property for a field that is not of type SinglePicklist or MultiplePicklist. |
ValueType
Gets or sets the type of value that can be associated with this field.
Declaration
public FieldValueType ValueType { get; set; }
Property Value
Type | Description |
---|---|
FieldValueType |
Methods
Clone()
Creates a deep copy of this field definition.
Declaration
public FieldDefinition Clone()
Returns
Type | Description |
---|---|
FieldDefinition | A copy of this field definition. |
Remarks
The field definition returned
CreateValue()
Creates a FieldValue instance, with the same name and type as this field declaration.
Declaration
public FieldValue CreateValue()
Returns
Type | Description |
---|---|
FieldValue | A FieldValue instance which is compatible with this field declaration. |