Class FieldDefinitions
Encapsulates a set of field declarations. Fields are identified through their name or through their GUID. Note that field names are case-insensitive.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemory
Assembly: Sdl.LanguagePlatform.TranslationMemory.dll
Syntax
public class FieldDefinitions : IEnumerable<Field>, IEnumerable, IFieldDefinitions
Constructors
FieldDefinitions()
Initializes a new instance with an empty field declaration list.
Declaration
public FieldDefinitions()
FieldDefinitions(FieldDefinitions)
Initializes a new instance, copying the field declarations from the provided collection (deep copy).
Declaration
public FieldDefinitions(FieldDefinitions other)
Parameters
Type | Name | Description |
---|---|---|
FieldDefinitions | other |
FieldDefinitions(ICollection<Field>)
Initializes a new instance, copying the field declarations from the provided collection (deep copy).
Declaration
public FieldDefinitions(ICollection<Field> fields)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.ICollection<Field> | fields |
Properties
Count
Gets the number of fields in this collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Fields
Gets the underlying list of field declarations.
Declaration
public ICollection<Field> Fields { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<Field> |
Item[Guid]
Gets the field with the specified GUID, or null
if there is no field with that
GUID.
Declaration
public Field this[Guid guid] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Guid | guid |
Property Value
Type | Description |
---|---|
Field |
Item[String]
Gets the field with the specified name, or null
if there is no field with that
name. Field names are case-insensitive.
Declaration
public Field this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The field name to look up |
Property Value
Type | Description |
---|---|
Field | The field, or |
Methods
Add(Field)
Adds a new field to the list. Throws an error if the field already exists or if no additions are allowed.
Declaration
public void Add(Field f)
Parameters
Type | Name | Description |
---|---|---|
Field | f | The field. |
Add(String, FieldValueType)
Creates a new field declaration with the specified name and type and adds it to the list.
Declaration
public Field Add(string fieldName, FieldValueType fieldType)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldName | The field name. |
FieldValueType | fieldType | The field type. |
Returns
Type | Description |
---|---|
Field | The newly created field declaration or an error if the field already exists. |
Clear()
Remove all the fields currently associated with this definition.
Declaration
public void Clear()
Contains(String)
Determines whether a named field exists in the collection. Field names are case-insensitive.
Declaration
public bool Contains(string fieldName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldName | The name of the field to look up. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Exists(Field)
Retrieves a value indicating whether the specified field exists in the collection. Only the name, not the data type, is checked.
Declaration
public bool Exists(Field f)
Parameters
Type | Name | Description |
---|---|---|
Field | f | The field. |
Returns
Type | Description |
---|---|
System.Boolean | true if a field with such a name exists, otherwise false. |
Exists(String)
Retrieves a value indicating whether a field with the specified name exists.
Declaration
public bool Exists(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The field name. |
Returns
Type | Description |
---|---|
System.Boolean | true if the such a field exists, otherwise false. |
GetEnumerator()
Returns an enumerator which can be used to iterate through the field list.
Declaration
public IEnumerator<Field> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<Field> | An enumerator |
Lookup(Guid)
Retrieves a field by its GUID.
Declaration
public Field Lookup(Guid guid)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | guid | The GUID to look up |
Returns
Type | Description |
---|---|
Field | The field with the specified GUID, or |
Lookup(String)
Retrieves the field declaration with the specified name. Field names are case-insensitive.
Declaration
public Field Lookup(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The field name. |
Returns
Type | Description |
---|---|
Field | The field declaration or null if it does not exist. |
LookupIField(Guid)
Returns the field with the specified GUID, or null
if there is no field with that
GUID.
Declaration
public IField LookupIField(Guid guid)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | guid |
Returns
Type | Description |
---|---|
IField |
LookupIField(String)
Returns the field with the specified name, or null
if there is no field with that
name.
Declaration
public IField LookupIField(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type | Description |
---|---|
IField |
Remove(Field)
Removes the field with the same name as the provided field, if one exists.
Declaration
public bool Remove(Field f)
Parameters
Type | Name | Description |
---|---|---|
Field | f | The field to remove. Only the name is checked. |
Returns
Type | Description |
---|---|
System.Boolean | True if the field has been removed, false otherwise. |
Remove(String)
Removes the field with the provided name, if one exists.
Declaration
public bool Remove(string fieldName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fieldName | The name of the field to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if the field has been removed, false otherwise. |
ToList()
Generates and returns a deep copy of the field declarations.
Declaration
public List<Field> ToList()
Returns
Type | Description |
---|---|
System.Collections.Generic.List<Field> |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator which can be used to iterate through the field list.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An enumerator |