Class ArrayType
A abstract LogixType that represents an array of other logix types (either atomic or structure).
public abstract class ArrayType : LogixType, ILogixSerializable, IEnumerable
- Inheritance
-
ArrayType
- Implements
- Derived
-
ArrayType<TLogixType>
- Inherited Members
Remarks
This class implements some of the base array type functionality for the generic derived class ArrayType<TLogixType>, but is abstract to force instantiation of the generic class.
Constructors
ArrayType(Array)
Creates a new array type from the provided array object.
protected ArrayType(Array array)
Parameters
array
ArrayAn array of logix types. Array can not be empty, contain null items, or objects of different logix type.
Exceptions
- ArgumentNullException
array
is null.- ArgumentException
array
contains no elements,null
orNullType
elements, or objects with different logix type names.- ArgumentOutOfRangeException
array
rank is greater than 3 dimensions.
ArrayType(XElement)
protected ArrayType(XElement element)
Parameters
element
XElementThe element to parse.
Exceptions
- ArgumentNullException
element
is null.- InvalidOperationException
element
does not have required attributes or child elements.
Properties
Class
The class (atomic, predefined, user-defined) that the type belongs to.
public override DataTypeClass Class { get; }
Property Value
- DataTypeClass
A DataTypeClass option representing the class type.
Dimensions
The dimensions of the the array, which define the length and rank of the array's elements.
public Dimensions Dimensions { get; }
Property Value
- Dimensions
A Dimensions value representing the array dimensions.
Remarks
Array type must have non-empty dimensions to be constructed.
Family
The family (string or none) of the type.
public override DataTypeFamily Family { get; }
Property Value
- DataTypeFamily
A DataTypeFamily option representing the family value.
this[ushort]
Gets the LogixType instance at the specified index.
public LogixType this[ushort x] { get; set; }
Parameters
x
ushortThe index of the array element
Property Value
Exceptions
- ArgumentOutOfRangeException
index
is out of range of the array.
this[ushort, ushort]
Gets the LogixType instance at the specified index.
public LogixType this[ushort x, ushort y] { get; set; }
Parameters
Property Value
Exceptions
- ArgumentOutOfRangeException
index
is out of range of the array.
this[ushort, ushort, ushort]
Gets the LogixType instance at the specified index.
public LogixType this[ushort x, ushort y, ushort z] { get; set; }
Parameters
x
ushortThe x index of the array element
y
ushortThe y index of the array element
z
ushortThe z index of the array element
Property Value
Exceptions
- ArgumentOutOfRangeException
index
is out of range of the array.
Members
The collection of LogixMember objects that make up the structure of the type.
public override IEnumerable<LogixMember> Members { get; }
Property Value
- IEnumerable<LogixMember>
A IEnumerable<T> containing LogixMember objects.
Remarks
All logix types, with the exception of a BOOL
and REAL/LREAL
, have what can be considered
members. Every derived type must implement this property for which it returns a collection of members, forming
the type/member hierarchy of the logix type.
Name
The name of the logix type.
public override string Name { get; }
Property Value
Remarks
The name of an array type will be the name of it's contained element types with the dimensions index text appended. This helps differentiate types when querying so we don't return both the base type and arrays of the specified base type. This is also similar to how the name appears from the logix designer.
Radix
Gets the radix format of the the array type elements.
public Radix Radix { get; }
Property Value
TypeName
The name of the logix type the array contains.
public string TypeName { get; }
Property Value
Remarks
This is used to delineate from the Name property of the array type which is the type name and the dimensions index concatenated. The type name is used for serialization.
Methods
GetIndex<TLogixType>(string)
Handles getting the logix type at the specified index of the current array from the underlying member collection.
protected TLogixType GetIndex<TLogixType>(string index) where TLogixType : LogixType
Parameters
index
stringThe index at which to get the type.
Returns
- TLogixType
A LogixType at the specified index.
Type Parameters
TLogixType
Exceptions
- ArgumentOutOfRangeException
index
is out of range of the array.
New<TLogixType>(Dimensions)
Creates a new ArrayType<TLogixType> of the specified type with the length of the provided dimensions.
public static ArrayType<TLogixType> New<TLogixType>(Dimensions dimensions) where TLogixType : LogixType, new()
Parameters
dimensions
DimensionsThe dimensions of the array to create.
Returns
- ArrayType<TLogixType>
A ArrayType<TLogixType> of the specified dimensions containing new objects of the specified type.
Type Parameters
TLogixType
The logix type for which to create. Must have a default parameterless constructor in order to generate instances.
Of<TLogixType>()
Casts the current ArrayType to an ArrayType<TLogixType> of the specified logix type generic parameter.
public ArrayType<TLogixType> Of<TLogixType>() where TLogixType : LogixType
Returns
- ArrayType<TLogixType>
A ArrayType<TLogixType> of the specified.
Type Parameters
TLogixType
The logix type to cast.
Serialize()
Returns a XElement representing the serialized L5X data for a given object.
public override XElement Serialize()
Returns
SetIndex<TLogixType>(string, TLogixType)
Handles setting the logix type at the specified index of the underlying member collection.
protected void SetIndex<TLogixType>(string index, TLogixType value) where TLogixType : LogixType
Parameters
index
stringThe index at which to set the type.
value
TLogixTypeThe logix type value to set.
Type Parameters
TLogixType
Exceptions
- ArgumentOutOfRangeException
index
is out of range of the array.