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

AF SDK Reference

AFLibrary Class

  • Last UpdatedNov 18, 2025
  • 6 minute read
AFLibrary Class
The AFLibrary is a collection of application or domain information that can be imported into an PISystem.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AFAFLibrary

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

Syntax

[SerializableAttribute]
public sealed class AFLibrary : AFObject, 
	IComparable<AFLibrary>
<SerializableAttribute>
Public NotInheritable Class AFLibrary
	Inherits AFObject
	Implements IComparable(Of AFLibrary)

Dim instance As AFLibrary
[SerializableAttribute]
public ref class AFLibrary sealed : public AFObject, 
	IComparable<AFLibrary^>
[<SealedAttribute>]
[<SerializableAttribute>]
type AFLibrary =  
    class
        inherit AFObject
        interface IComparable<AFLibrary>
    end

The AFLibrary type exposes the following members.

Properties

  NameDescription
Public property
Created
The time that the library file was created.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
ID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
Name
Read/write property that identifies the name of the object.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
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 AFObject.)
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
GetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
Import(AFDatabase)
Imports the library into the PISystem and the specified AFDatabase.
Public method
Import(AFDatabase, EventHandlerAFProgressEventArgs)
Imports the library into the PISystem and the specified AFDatabase.
Public method
Persist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)

Remarks

Libraries are created by exporting a PISystem into XML format and loading the XML into the PI AF Server, through one of the AFLibrariesAdd methods.

Examples

// This example will create a new library and import it into a new Database. 

// Create a new Database on the default PI System
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;

// Create a new library
AFDatabase myLibDB = myPISystem.Databases.Add("MyLibDB");
AFElementTemplate myElemTemplate = myLibDB.ElementTemplates.Add("MyElemTemplate");
AFAttributeTemplate myAttributeTemplate = myElemTemplate.AttributeTemplates.Add("MyAttribute1");
myLibDB.CheckIn();
AFLibrary library = myPISystem.Libraries.Add(myLibDB, "Standard");
library.Description = "This is the standard library.";

// Get the standard Library
library = myPISystem.Libraries["Standard"];
Console.WriteLine("Current number of Libraries = {0}", myPISystem.Libraries.Count);

AFDatabase myDB = myPISystem.Databases.Add("MyDB");
if (library != null)
{
    // Display Library information
    Console.WriteLine("Description of Library = {0}", library.Description);
    Console.WriteLine("Name of Library = {0}", library.Name);
    Console.WriteLine("UniqueID of Library = {0}", library.UniqueID);

    // Import the Library into the Database
    library.Import(myDB);
}
' This example will create a new library and import it into a new Database. 

' Create a new Database on the default PI System
Dim myPISystems As New PISystems()
Dim myPISystem As PISystem = myPISystems.DefaultPISystem

' Create a new library
Dim myLibDB As AFDatabase = myPISystem.Databases.Add("MyLibDB")
Dim myElemTemplate As AFElementTemplate = myLibDB.ElementTemplates.Add("MyElemTemplate")
Dim myAttributeTemplate As AFAttributeTemplate = myElemTemplate.AttributeTemplates.Add("MyAttribute1")
myLibDB.CheckIn()
Dim library As AFLibrary = myPISystem.Libraries.Add(myLibDB, "Standard")
library.Description = "This is the standard library."

' Get the standard Library
library = myPISystem.Libraries("Standard")
Console.WriteLine("Current number of Libraries = {0}", myPISystem.Libraries.Count)

Dim myDB As AFDatabase = myPISystem.Databases.Add("MyDB")
If library IsNot Nothing Then
    ' Display Library information
    Console.WriteLine("Description of Library = {0}", library.Description)
    Console.WriteLine("Name of Library = {0}", library.Name)
    Console.WriteLine("UniqueID of Library = {0}", library.UniqueID)

    ' Import the Library into the Database
    library.Import(myDB)
End If

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

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