Table of Contents

Class StructureType

Namespace
L5Sharp.Types
Assembly
L5Sharp.dll

A LogixType that represents a structure containing members of different types.

public abstract class StructureType : LogixType, ILogixSerializable
Inheritance
StructureType
Implements
Derived
Inherited Members

Remarks

This type is a building block for all Predefined data types. Inherit from this class to create custom user defined data types that can be used to create in memory representation of the tags for those types. Inherit from ComplexType if you want the ability to mutate the member structure after instantiation.

Constructors

StructureType(string)

Creates a new StructureType instance.

protected StructureType(string name)

Parameters

name string

The name of the type.

Exceptions

ArgumentException

name is null or empty.

StructureType(string, IEnumerable<LogixMember>)

Creates a new StructureType with the provided name and collection of LogixMember objects.

protected StructureType(string name, IEnumerable<LogixMember> members)

Parameters

name string

The name of the structure type.

members IEnumerable<LogixMember>

The members of the structure type.

Exceptions

ArgumentException

name is null or empty.

ArgumentNullException

members is null.

StructureType(XElement)

Creates a new StructureType initialized from the provided XElement data.

protected StructureType(XElement element)

Parameters

element XElement

The element to parse as the new member object.

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.

Family

The family (string or none) of the type.

public override DataTypeFamily Family { get; }

Property Value

DataTypeFamily

A DataTypeFamily option representing the family value.

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

string

A string name identifying the logix type.

Methods

AddMember(LogixMember)

Adds the provided member to the structure type.

protected void AddMember(LogixMember member)

Parameters

member LogixMember

The member to add.

Exceptions

ArgumentNullException

member is null.

AddMembers(ICollection<LogixMember>)

Adds the provided collection of members to the structure type.

protected void AddMembers(ICollection<LogixMember> members)

Parameters

members ICollection<LogixMember>

The collection of members to add.

Exceptions

ArgumentNullException

members is null or any member in members is null.

ClearMembers()

Clears all members from the structure type.

protected void ClearMembers()

GetMember<TLogixType>(string?)

Gets the logix type for the specified member.

protected TLogixType GetMember<TLogixType>(string? name = null) where TLogixType : LogixType

Parameters

name string

The member name to find.

Returns

TLogixType

A LogixType representing the data of the specified member.

Type Parameters

TLogixType

The logix type to return.

Remarks

This method is for users implementing custom user defined or predefined types. Use this as the getter for all member's logix types. The user of CallerMemberName allows the member name to be omitted assuming it matches the name of the calling property.

Exceptions

InvalidOperationException

A member with the specified name was not found in the member collection.

InsertMember(int, LogixMember)

Inserts the provided member at the specified index of the structure type.

protected void InsertMember(int index, LogixMember member)

Parameters

index int

The zero-based index at which item should be inserted.

member LogixMember

The member to insert.

Exceptions

ArgumentNullException

member is null.

ArgumentOutOfRangeException

index is less than 0. -or- index is greater than the length of the member collection.

OnMemberDataChanged(object, EventArgs)

Raises the local logix type DataChanged event, allowing nested member data change event to bubble up the to the root member.

protected virtual void OnMemberDataChanged(object sender, EventArgs e)

Parameters

sender object

The object that initiated the data change event.

e EventArgs

The event arguments of the data changed event.

RemoveMember(int)

Removes a member at the specified index from the structure type.

protected void RemoveMember(int index)

Parameters

index int

The zero-based index of the member to remove.

RemoveMember(string)

Removes a member with the specified name from the structure type.

protected void RemoveMember(string name)

Parameters

name string

The name of the member to remove.

ReplaceMember(int, LogixMember)

Replaces a member at the specified index with the provided member instance.

protected void ReplaceMember(int index, LogixMember member)

Parameters

index int

The zer-based index at which to replace the member.

member LogixMember

The member to replace the current member with.

Exceptions

ArgumentNullException

member is null.

ReplaceMember(string, LogixMember)

Replaces a member having the specified name with the provided member instance.

protected void ReplaceMember(string name, LogixMember member)

Parameters

name string

The name of the member to replace.

member LogixMember

The member to replace the current member with.

Exceptions

ArgumentNullException

member is null.

ArgumentException

name does not exists in the structure type.

ReplaceMember(string, LogixType)

Replaces a member having the specified name with a new member instance of the same name and provided LogixType.

protected void ReplaceMember(string name, LogixType type)

Parameters

name string

The name of the member to replace.

type LogixType

The LogixType data to update the specified member with.

Exceptions

ArgumentNullException

type is null.

ArgumentException

name does not exists in the structure type.

Serialize()

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

public override XElement Serialize()

Returns

XElement

A XElement containing the XML data.

SetMember<TLogixType>(TLogixType, string?)

Adds or updates the specified member's logix type with the provided value.

protected void SetMember<TLogixType>(TLogixType value, string? name = null) where TLogixType : LogixType

Parameters

value TLogixType

The logix type value to set.

name string

The name of the member to set.

Type Parameters

TLogixType

The logix type parameter of the member.

Remarks

This method is for users implementing custom user defined or predefined types. Use this as the setter for all members of the type.

Internally this will update the underlying member collection. If the member already exists, the data type value will be set to the provided value, otherwise a new member will be added at the end of the member collection. This allows the user to initialize member properties in a default constructor in the derived class. Note that the order in which members exist in the underlying collection matters when importing logix type tag data.

Exceptions

ArgumentNullException

name or value is null.