Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFAttributes Class

  • Last UpdatedNov 18, 2025
  • 9 minute read
AFAttributes Class
A collection of AFAttribute objects. This may be the collection of attributes maintained by an AFBaseElement or by another AFAttribute.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFCollection
    OSIsoft.AFAFCollectionAFAttribute
      OSIsoft.AFAFNamedCollectionAFAttribute
        OSIsoft.AF.AssetAFAttributes

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public sealed class AFAttributes : AFNamedCollection<AFAttribute>, 
	IAFNamedCollection<IAFAttribute>, ICollection<IAFAttribute>, IEnumerable<IAFAttribute>, 
	IEnumerable, IList<IAFAttribute>
Public NotInheritable Class AFAttributes
	Inherits AFNamedCollection(Of AFAttribute)
	Implements IAFNamedCollection(Of IAFAttribute), ICollection(Of IAFAttribute), 
	IEnumerable(Of IAFAttribute), IEnumerable, IList(Of IAFAttribute)

Dim instance As AFAttributes
public ref class AFAttributes sealed : public AFNamedCollection<AFAttribute^>, 
	IAFNamedCollection<IAFAttribute^>, ICollection<IAFAttribute^>, IEnumerable<IAFAttribute^>, 
	IEnumerable, IList<IAFAttribute^>
[<SealedAttribute>]
type AFAttributes =  
    class
        inherit AFNamedCollection<AFAttribute>
        interface IAFNamedCollection<IAFAttribute>
        interface ICollection<IAFAttribute>
        interface IEnumerable<IAFAttribute>
        interface IEnumerable
        interface IList<IAFAttribute>
    end

The AFAttributes type exposes the following members.

Properties

  NameDescription
Public property
Count
Gets the number of items actually contained in the collection.
(Inherited from AFCollectionT.)
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Element
This property returns the AFBaseElement object which owns the attribute collection.
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFCollection.)
Public property
IsDeleted
This read-only property indicates whether the owner of the collection has been deleted.
(Inherited from AFCollection.)
Public property
ItemGuid
Returns the item in the collection associated with the passed in ID.
(Inherited from AFCollectionT.)
Public property
ItemInt32
Returns the item located at the passed in index.
(Inherited from AFCollectionT.)
Public property
ItemString
Returns the specified object from the collection by name.
(Inherited from AFNamedCollectionT.)
Public property
ItemIdentity
This read-only property specifies the identity of the objects within the collection.
(Inherited from AFCollection.)
Public property
Parent
This read-only property returns the AFAttribute that owns this collection of attributes.
Public property
PISystem
This read-only property allows access to the PISystem associated with this collection.
(Inherited from AFCollection.)

Methods

  NameDescription
Public method
Add(T)
Adds an object to the end of the collection.
(Inherited from AFCollectionT.)
Public method
Add(String)
The Add method creates a new object and adds it to the collection.
Public method
Clear
Removes all items from the collection.
(Inherited from AFCollectionT.)
Public method
Contains(Guid)
This method determines whether the collection contains a specific item referenced by id.
(Inherited from AFCollectionT.)
Public method
Contains(T)
This method determines whether the collection contains a specific item.
(Inherited from AFCollectionT.)
Public method
Contains(String)
This method determines whether the collection contains a specific item referenced by name.
(Inherited from AFNamedCollectionT.)
Public method
CopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
(Inherited from AFCollectionT.)
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
GetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from AFCollectionT.)
Public method
GetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from AFCollection.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
GetValue
This method gets the value for each attribute in the list based upon its data reference configuration.
Public method
GetValue(AFCase)
This method gets the value for each attribute in the list based upon its data reference configuration and the specified AFCase context.
Public method
GetValue(AFTime)
This method gets the value for each attribute in the list based upon its data reference configuration and the specified AFTime context.
Public method
GetValue(AFTimeRange)
This method gets the value for each attribute in the list based upon its data reference configuration and the specified AFTimeRange context.
Public method
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
(Inherited from AFCollectionT.)
Public method
Remove(Guid)
Removes the item with the specified id from the collection.
(Inherited from AFCollectionT.)
Public method
Remove(T)
Removes the first occurrence of a specific object from the collection.
(Inherited from AFCollectionT.)
Public method
Remove(String)
The Remove method removes the item from the collection by name.
(Inherited from AFNamedCollectionT.)
Public method
RemoveAt
Removes the item at the specified index of the collection.
(Inherited from AFCollectionT.)
Public method
Sort
Sorts the items in the entire collection using the default comparer.
(Inherited from AFCollectionT.)
Public method
Sort(IComparerT)
Sorts the items in the entire collection using the specified comparer.
(Inherited from AFCollectionT.)
Public method
Sort(Int32, Int32, IComparerT)
Sorts the items in a range of items in the collection using the specified comparer.
(Inherited from AFCollectionT.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFCollection.)

Extension Methods

  NameDescription
Public Extension MethodCode example
ChunkedByIAFAttribute
This extension method breaks up search results into chunks to make it easier to page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.)

Remarks

Each of the following types derived from AFBaseElement contain a collection of attributes: AFElement, AFModel, AFEventFrame, AFTransfer, AFCase, and AFNotification. An AFAttribute object also has an AFAttributes collection which allows the creation of a hierarchy of attributes within the element.

The set of attributes for an element is a combination of those created from the template, and if allowed by the AllowElementToExtend setting, those added individually to the element. The template based attributes are created from the collection of AFAttributeTemplates in the AFElementTemplate that is used to create the element. An attribute is created for all attribute templates defined by the template plus any additional attribute templates defined by the base templates.

When using the ItemString collection indexer to find an attribute by string, you can use a name like most other collections or a path to an attribute. When using a path, it is normally relative to the owning element or parent attribute, but can be a full path to any attribute. For example, the following are valid when looking up an attribute by path:

  • MyParentAttribute["Child1|Child2"]
  • MyParentAttribute["..|OtherAttribute|ChildAttribute"]
  • MyParentAttribute["\\MySystem\MyDatabase\OtherElement|OtherAttribute|ChildAttribute"]

To create a list of unrelated attributes, use the AFAttributeList collection.

Examples

// This example demonstrates how to create an attribute for an
// element and display information about it.

// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
AFDatabase myDB = myPISystem.Databases.DefaultDatabase;

// Create an Element
AFElement myElement = myDB.Elements.Add("MyElement");

// Create an Attribute
AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute");
myAttribute.Description = "Attribute for MyElement";
myAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs["kelvin"];
myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem);

// An example of a valid configuration string:
// "\\%Server%\sinusoid;ptclassname=classic;pointtype=Float32;pointsource=R;descriptor=""12 Hour Sine Wave"";location2=2;location4=1"
myAttribute.ConfigString = myConfigString;

// Get Value
AFValue myValue = myAttribute.GetValue(myPISystem.UOMDatabase.UOMs["degree Celsius"]);
Console.WriteLine("Attribute Template Value = {0} {1}", myValue.Value, myValue.UOM);

// Display Attribute Information
foreach (AFAttribute CurAttribute in myElement.Attributes)
{
    Console.WriteLine("Name of Attribute = {0}", CurAttribute.Name);
    Console.WriteLine("Description = {0}", CurAttribute.Description);
    Console.WriteLine("Default UOM = {0}", CurAttribute.DefaultUOM.Name);
    Console.WriteLine("DataReference = {0}", CurAttribute.DataReference.Name);
    Console.WriteLine("ConfigString = {0}", CurAttribute.ConfigString);
}
' This example demonstrates how to create an attribute for an
' element and display information about it.

' Get the Database
Dim myPISystems As New PISystems
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase

' Create An Element
Dim myElement As AFElement = myDB.Elements.Add("MyElement*")

' Create an Attribute
Dim CurAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute")
CurAttribute.Description = "Attribute for MyElement"
CurAttribute.DefaultUOM = myPISystem.UOMDatabase.UOMs("Kelvin")
CurAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem)

' An example of a valid configuration string
' "\\%Server%\sinusoid;ptclassname=classic;pointtype=Float32;pointsource=R;descriptor=""12 Hour Sine Wave"";location2=2;location4=1"
CurAttribute.ConfigString = myConfigString

'Get Value
Dim myValue As AFValue = CurAttribute.GetValue(myPISystem.UOMDatabase.UOMs("degree Celsius"))
Console.WriteLine("Attribute Template Value = {0} {1}", myValue.Value, myValue.UOM)

' Display Attribute Information
For Each CurAttribute In myElement.Attributes
    Console.WriteLine("Name of Attribute = {0}", CurAttribute.Name)
    Console.WriteLine("Description = {0}", CurAttribute.Description)
    Console.WriteLine("Default UOM = {0}", CurAttribute.DefaultUOM.Name)
    Console.WriteLine("DataReference = {0}", CurAttribute.DataReference.Name)
    Console.WriteLine("ConfigString = {0}", CurAttribute.ConfigString)
Next CurAttribute

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

TitleResults for “How to create a CRG?”Also Available in