Class Field
Represents a field declaration.
Inherited Members
Namespace: SdlSdl.LanguagePlatformTranslationMemory
Assembly: Sdl.LanguagePlatform.TranslationMemory.dll
Syntax
[DataContract]
[KnownType(typeof(PicklistField))]
public class Field : PersistentObject, ICloneable, IField
Constructors
Field()
Initializes a new instance with an empty resource token.
Declaration
public Field()
Field(Field)
Initializes a new instance with the values of another instance, creating a deep copy.
Declaration
public Field(Field other)
Parameters
Type | Name | Description |
---|---|---|
Field | other | The other instance |
Field(string, FieldValueType)
Initializes a new instance, with the specified name and type.
Declaration
public Field(string name, FieldValueType valueType)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name. |
FieldValueType | valueType | The field type. |
Fields
StructureContextFieldName
The name for the structure context field name.
Declaration
public static readonly string StructureContextFieldName
Field Value
Type | Description |
---|---|
string |
TextContextFieldName
A pseudo-name for the text context field. Since text context values are directly stored at the TU, and not represented as field values, this pseudo field name is only relevant for edit scripts.
Declaration
public static readonly string TextContextFieldName
Field Value
Type | Description |
---|---|
string |
Properties
FieldType
Gets the type of the field, i.e. whether it is a system or user-defined field.
Declaration
[DataMember]
public FieldType FieldType { get; set; }
Property Value
Type | Description |
---|---|
FieldType |
IsSystemField
Gets a flag which indicates that this field is a system field. System fields cannot be changed or deleted by the user. Setting this flag from user-code has no effect.
Declaration
public bool IsSystemField { get; }
Property Value
Type | Description |
---|---|
bool |
Name
Gets or sets the field name.
Declaration
[DataMember]
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
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 virtual IList<string> PicklistItemNames { get; }
Property Value
Type | Description |
---|---|
IListstring |
ValueType
Gets or sets the field value type.
Declaration
[DataMember]
public FieldValueType ValueType { get; set; }
Property Value
Type | Description |
---|---|
FieldValueType |
Methods
CheckName(string)
Checks the given name and throws an exception if the name is not valid.
Declaration
protected virtual void CheckName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | name |
Clone()
Declaration
public virtual object Clone()
Returns
Type | Description |
---|---|
object | A new object that is a deep copy of this instance. |
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. |
Duplicate()
Creates a new instance that is a deep copy of this instance.
Declaration
public virtual Field Duplicate()
Returns
Type | Description |
---|---|
Field | A new instance that is a deep copy of this instance. |
Equals(object)
Determines whether this instance of Field and a specified object, which must also be a Field object, represent the same field declaration including the picklist according to type.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The other object. |
Returns
Type | Description |
---|---|
bool | true if obj represents the same field declaration as this instance; false otherwise. |
Overrides
EqualsDeclaration(Field)
Determines whether this instance of Field and a specified object, which must also be a Field object, represent the same field declaration, not considering the picklist.
Declaration
public bool EqualsDeclaration(Field other)
Parameters
Type | Name | Description |
---|---|---|
Field | other | The other object. |
Returns
Type | Description |
---|---|
bool | true if other represents the same declaration but might have a different picklist; false otherwise. |
GetFieldType(string)
Determine the field type, given the field name.
Declaration
public static FieldType GetFieldType(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name to determine the field type for |
Returns
Type | Description |
---|---|
FieldType | The field type, if it can be determined, or FieldType.User if the field name is not reserved for system prposes. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
IsPseudoFieldName(string)
Determines whether the name is reserved for a pseudo (non-physical) field.
Declaration
public static bool IsPseudoFieldName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name to check |
Returns
Type | Description |
---|---|
bool |
|
IsReservedName(string)
Determines whether the name is reserved for system purposes.
Declaration
public static bool IsReservedName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name to check |
Returns
Type | Description |
---|---|
bool |
|
IsSystemFieldName(string)
Determines whether the specified name is reserved for a system (predefined) field.
Declaration
public static bool IsSystemFieldName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name to check |
Returns
Type | Description |
---|---|
bool |
|
IsValidName(string)
Determines whether a specified string can be used as a field name.
All field names are valid if they don't start or end with whitespace.
Declaration
public static bool IsValidName(string val)
Parameters
Type | Name | Description |
---|---|---|
string | val | The string. |
Returns
Type | Description |
---|---|
bool | true if the string is a legal identifier, false otherwise. |
LookupSpecialField(string)
Looks up a special field by its name. Special fields are fields with a predefined name, which may be "virtual" fields (those computed from data at runtime) or "physical" fields (which have an actual value in the data storage). Special field names should not be used for user-defined fields. Note that special fields are a superset of system fields (i.e. not all special fields are system fields).
Declaration
public static Field LookupSpecialField(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The field name |
Returns
Type | Description |
---|---|
Field | The special (predefined) field, or |
RemoveIllegalChars(string)
Removes those characters from an input string which are not allowed in field names, and returns the form that will be accepted as a field name identifier. This method should only be used when fields are automatically added by some process (e.g. by importing a TMX file) and that process should be robust and continue despite invalid field names.
Declaration
public static string RemoveIllegalChars(string val)
Parameters
Type | Name | Description |
---|---|---|
string | val | The input string. |
Returns
Type | Description |
---|---|
string | The string after the illegal characters have been removed. |