Class SkeletonCollection<T>
Base class for collections used in a FileSkeleton.
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.TranslationMemoryApi.LiteBCM.Skeleton
Assembly: Sdl.LanguagePlatform.TranslationMemoryApi.dll
Syntax
public class SkeletonCollection<T> : KeyBasedCollection<SkeletonCollectionKey, T>, IList<T>, ICollection<T>, IEnumerable<T>, IEnumerable, IEquatable<KeyBasedCollection<SkeletonCollectionKey, T>> where T : SkeletonItem
Type Parameters
Name | Description |
---|---|
T |
Constructors
SkeletonCollection()
Instantiates a new instance of the SkeletonCollection<T> class.
Declaration
public SkeletonCollection()
SkeletonCollection(IList<T>)
Instantiates a new instance of the SkeletonCollection<T> class starting with a given enumeration of items.
Declaration
public SkeletonCollection(IList<T> items)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | items | The items to be used to seed the collection. |
Properties
IdGenerator
Gets the IdGenerator.
Declaration
public IdGenerator IdGenerator { get; }
Property Value
Type | Description |
---|---|
IdGenerator | The IdGenerator. |
ParentSkeleton
Gets or sets the parent FileSkeleton.
Declaration
public FileSkeleton ParentSkeleton { get; }
Property Value
Type | Description |
---|---|
FileSkeleton | The parent FileSkeleton. |
Methods
GetById(Int32)
Gets an element by its numerical id.
Declaration
public T GetById(int id)
Parameters
Type | Name | Description |
---|---|---|
Int32 | id | The id. |
Returns
Type | Description |
---|---|
T | If found, returns the element with the Id |
GetOrAdd(T)
Gets the element if it already exists in the collection. Otherwise, it is added to the collection and gives it the next ID in the IdGenerator sequence.
Declaration
public T GetOrAdd(T elem)
Parameters
Type | Name | Description |
---|---|---|
T | elem | The element. |
Returns
Type | Description |
---|---|
T | The existing element; or the newly added one with an Id set. |
GetOrAddWithExistingId(T)
Gets the element if it already exists in the collection. Otherwise, it is added to the collection (preserving its existing ID).
Declaration
public T GetOrAddWithExistingId(T elem)
Parameters
Type | Name | Description |
---|---|---|
T | elem | The element. |
Returns
Type | Description |
---|---|
T | The existing element; or the newly added one with an Id set. |
OnItemAdded(T)
Ensures the item has an Id set according to the IdGenerator owned by the skeleton. This is only performed if the item has id 0, otherwise it is left untouched.
Declaration
protected override void OnItemAdded(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to have id calculated if needed. |