Table of Contents

Class LogixContainer<TElement>

Namespace
L5Sharp
Assembly
L5Sharp.dll

A generic collection that provides operations over an underlying XElement container of LogixElement objects.

public class LogixContainer<TElement> : IEnumerable<TElement>, IEnumerable, ILogixSerializable where TElement : LogixElement

Type Parameters

TElement

The type inheriting LogixElement.

Inheritance
LogixContainer<TElement>
Implements
IEnumerable<TElement>
Inherited Members

Remarks

This class represents a wrapper around a L5X element that contains a sequence of child elements of the same type. This class exposes collection methods for querying and modifying child elements of the container. Note that a container could potentially contain more than one type of child element, but this container class will only operate over the specified element type.

The class is designed to only offer very basic operations, allowing it to be applicable to all container type elements, However, the user can extended the API for any container type using extension methods and Serialize() to get the underlying XElement container object. See LogixExtensions for examples.

Constructors

LogixContainer()

Creates a empty LogixContainer<TElement> with the default type name.

public LogixContainer()

LogixContainer(IEnumerable<TElement>)

Creates a new LogixContainer<TElement> initialized with the provided collection.

public LogixContainer(IEnumerable<TElement> components)

Parameters

components IEnumerable<TElement>

The collection of elements to initialize.

LogixContainer(XElement)

Creates a new LogixContainer<TElement> initialized with the provided XElement.

public LogixContainer(XElement container)

Parameters

container XElement

The XElement containing a collection of elements.

Exceptions

ArgumentNullException

container is null.

LogixContainer(XName)

Creates a empty LogixContainer<TElement> with the specified type name.

public LogixContainer(XName name)

Parameters

name XName

The name of the container element.

Properties

this[int]

Accesses a single element at the specified index of the container collection.

public TElement this[int index] { get; set; }

Parameters

index int

The zero based index of the element to retrieve.

Property Value

TElement

The element at the specified position in the source container.

Exceptions

ArgumentOutOfRangeException

index is less than zero or greater than or equal to the number of elements in the collection.

ArgumentNullException

value is null when setting index.

Methods

Add(TElement)

Adds the provided element to the logix container at the end of the collection.

public void Add(TElement element)

Parameters

element TElement

The element to add.

Exceptions

ArgumentNullException

element is null.

AddRange(IEnumerable<TElement>)

Adds the provided elements to the logix container at the end of the collection.

public void AddRange(IEnumerable<TElement> elements)

Parameters

elements IEnumerable<TElement>

The collection of elements to add.

Exceptions

ArgumentNullException

elements or any element in elements is null.

Count()

Gets the number of elements in the collection.

public int Count()

Returns

int

A int representing the number of elements in the collection.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<TElement> GetEnumerator()

Returns

IEnumerator<TElement>

An enumerator that can be used to iterate through the collection.

Insert(int, TElement)

Inserts the provided element at the specified index of the container collection.

public void Insert(int index, TElement element)

Parameters

index int

The zero based index at which to insert the element.

element TElement

The element to insert.

Exceptions

ArgumentNullException

element is null.

ArgumentOutOfRangeException

index is less than zero or greater than or equal to the number of elements in the collection.

RemoveAll()

Removes all elements in the container collection.

public void RemoveAll()

RemoveAll(Func<TElement, bool>)

Removes all elements that satisfy the provided condition predicate.

public void RemoveAll(Func<TElement, bool> condition)

Parameters

condition Func<TElement, bool>

The condition for which to remove elements.

Exceptions

ArgumentNullException

condition is null.

RemoveAt(int)

Removes a element at the specified index of the collection.

public void RemoveAt(int index)

Parameters

index int

The zero based index of the element to remove.

Exceptions

ArgumentOutOfRangeException

index is less than zero or greater than or equal to the number of elements in the collection.

Serialize()

Returns a XElement representing the serialized L5X data for a given object.

public XElement Serialize()

Returns

XElement

A XElement containing the XML data.

Update(Action<TElement>)

Updates all elements in the container by applying the provided update action delegate.

public void Update(Action<TElement> update)

Parameters

update Action<TElement>

A update to apply to each element.

Exceptions

ArgumentNullException

update is null.

Update(Action<TElement>, Func<TElement, bool>)

Updates all elements in the container that satisfy the provided condition predicate by applying the provided update action delegate.

public void Update(Action<TElement> update, Func<TElement, bool> condition)

Parameters

update Action<TElement>

A update to apply to each element.

condition Func<TElement, bool>

The condition for which to update elements.

Exceptions

ArgumentNullException

update or condition is null.