You are here: Basics Operations & Concepts > Activation > Transparent Activation > Using TA Collections Directly

Using TA Collections Directly

You can use the transparent activation aware collections directly in your code. They behavior is the same as the .NET-collections. Here are a few tips:

An example:

public class Team : ActivatableBase
{
    private readonly IList<Pilot> pilots = new ActivatableList<Pilot>();

    public void Add(Pilot pilot)
    {
        Activate(ActivationPurpose.Write);
        pilots.Add(pilot);
    }

    public ICollection<Pilot> Pilots
    {
        get
        {
            Activate(ActivationPurpose.Read);
            return pilots;
        }
    }
}
Team.cs: Using the activation aware collections
Public Class Team
    Inherits ActivatableBase
    Private ReadOnly m_pilots As IList(Of Pilot) = New ActivatableList(Of Pilot)()

    Public Sub Add(ByVal pilot As Pilot)
        Activate(ActivationPurpose.Write)
        m_pilots.Add(pilot)
    End Sub

    Public ReadOnly Property Pilots() As ICollection(Of Pilot)
        Get
            Activate(ActivationPurpose.Read)
            Return m_pilots
        End Get
    End Property
End Class
Team.vb: Using the activation aware collections

Currently these collections are available: