Class AttributeCollection
Represents a collection of Attributes attached to a ProjectObject. Attributes are stored as a key/value pair. Keys can be associated with a Guid. A key with a Guid can only be removed by a client that knows the Guid.
Namespace: ABB.Robotics.RobotStudio
Assembly: ABB.Robotics.RobotStudio.dll
Syntax
public class AttributeCollection : ICollection, IEnumerable
Remarks
Add-Ins should consider associating attribute keys with a Guid to make sure that the attribute is not removed by accident by another Add-In. To avoid conflicts with attribute keys defined by RobotStudio or other Add-Ins, prefix the key with the Add-In name.
ProjectObjects that represent geometry entities (such as Body, Face and Wire) are not saved in the station file, therefore Attributes cannot be used to persist their attributes.
Properties
Count
Gets the number of elements contained in the AttributeCollection.
Declaration
public virtual int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsSynchronized
Gets a value indicating whether access to the AttributeCollection is synchronized (thread safe).
Declaration
public virtual bool IsSynchronized { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Gets the item at the specified index.
Declaration
public object this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | The zero-based index of the item to get. |
Property Value
Type | Description |
---|---|
Object | The item at the specified index. |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | The index value is greater than the number of items in the collection. |
Item[String]
Gets the item at the specified index.
Declaration
public object this[string key] { get; }
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the item to get. |
Property Value
Type | Description |
---|---|
Object | The item at the specified key. |
Exceptions
Type | Condition |
---|---|
ArgumentException | The key value is not in the collection. |
SyncRoot
Gets an object that can be used to synchronize access to the AttributeCollection.
Declaration
public virtual object SyncRoot { get; }
Property Value
Type | Description |
---|---|
Object |
Methods
Add(Guid, String, Object)
Adds a protected attribute to this AttributeCollection object. A protected attribute can only be modified or removed if the access id used when creating it is known.
Declaration
public void Add(Guid accessId, string key, object value)
Parameters
Type | Name | Description |
---|---|---|
Guid | accessId | The access id. |
String | key | The key to be added. |
Object | value | The value to be associated with key. The following types are allowed: Int32, Int16, Double, Boolean, String, ProjectObject |
Exceptions
Type | Condition |
---|---|
ArgumentException | The key is protected by an access id. |
Add(String, Object)
Add an attribute to this AttributeCollection object.
Declaration
public void Add(string key, object value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to be added. |
Object | value | The value to be associated with key, see remarks. |
Remarks
Add-Ins should prefix attribute keys with the Add-In name to avoid conflicts with other Add-Ins. For example the Add-In "CompanyABCAddIn" that stores a length value as an attribute could use a key named "CompanyABCAdd.Length". The following types are allowed for the value argument and arrays of these types: Int32, Int16, Double, Boolean, Single, String, ProjectObject, Matrix4, Vector3, Vector4 The matrix must be rigid.
Exceptions
Type | Condition |
---|---|
ArgumentException | The key is protected by a access id. |
NotSupportedException | The value type is not supported. |
NullReferenceException | An array may not contain values of null. |
ContainsAttributeKey(String)
Determines if the AttributeCollection contains a specific key.
Declaration
public bool ContainsAttributeKey(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key |
Returns
Type | Description |
---|---|
Boolean |
CopyTo(Array, Int32)
Copies the elements of the collection to an Array, starting at a particular Array index
Declaration
public virtual void CopyTo(Array array, int index)
Parameters
Type | Name | Description |
---|---|---|
Array | array | Destination Array |
Int32 | index | The zero-based index in targetArray at which copying begins |
CopyTo(Attribute[], Int32)
Copies the elements of the collection to an array, starting at a particular array index.
Declaration
public void CopyTo(Attribute[] array, int index)
Parameters
Type | Name | Description |
---|---|---|
Attribute[] | array | Destionation array |
Int32 | index | The zero-based index in targetArray at which copying begins. |
GetAttributeKeys()
Returns all keys in the AttributeCollection
Declaration
public string[] GetAttributeKeys()
Returns
Type | Description |
---|---|
String[] |
GetEnumerator()
Returns an IEnumerator that iterates over the keys in the AttributeCollection.
Declaration
public virtual IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | An IEnumerator for the AttributeCollection. |
HasAttributeAccessId(String)
Check if a key has a accessId connected.
Declaration
public bool HasAttributeAccessId(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key to check. |
Returns
Type | Description |
---|---|
Boolean | True if key has a accessId. |
Remove(Guid, String)
Removes a protected attribute from this AttributeCollection object.
Declaration
public void Remove(Guid accessId, string key)
Parameters
Type | Name | Description |
---|---|---|
Guid | accessId | The access id that was specified when the attribute was added. |
String | key | The key of the attribute to be removed. |
Exceptions
Type | Condition |
---|---|
ArgumentException | An attribute with the specified key has not been added to the collection or the key is protected by an access id. |
Remove(String)
Removes an attribute from this AttributeCollection object.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the attribute to be removed. |
Exceptions
Type | Condition |
---|---|
ArgumentException | An attribute with the specified key has not been added to the collection or the key is protected by an access id. |
TryGetValue(String, out Object)
Gets the value with the specified key.
Declaration
public bool TryGetValue(string key, out object value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the value to get. |
Object | value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, null. |
Returns
Type | Description |
---|---|
Boolean | true if the AttributeCollection contains an element with the specified key; otherwise, false. |
Exceptions
Type | Condition |
---|---|
ArgumentException | key is a null reference or empty. |
TryGetValue<T>(String, out T)
Gets the value with the specified key.
Declaration
public bool TryGetValue<T>(string key, out T value)
Parameters
Type | Name | Description |
---|---|---|
String | key | The key of the value to get. |
T | value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, null. |
Returns
Type | Description |
---|---|
Boolean | true if the AttributeCollection contains an element with the specified key; otherwise, false. |
Type Parameters
Name | Description |
---|---|
T |
Exceptions
Type | Condition |
---|---|
ArgumentException | key is a null reference or empty. |