Class FieldAttribute
This attribute is used to declare a specific field as a port. To use a field as a port the field type must derive from IPortType or PortList.
Namespace: Mechatronics.SystemGraph
Syntax
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter)]
public class FieldAttribute : Attribute, _Attribute
Constructors
FieldAttribute(String, PortDirection, FieldExtra)
Creates a FieldAttribute and checks for reserved charactes in the name.
Declaration
public FieldAttribute(string displayName, PortDirection dir, FieldExtra readWrite = FieldExtra.Undefined)
Parameters
| Type | Name | Description |
|---|---|---|
| String | displayName | Name of the port. |
| PortDirection | dir | Direction of the port. |
| FieldExtra | readWrite | The functions of the port, see FieldExtra. |
Fields
Direction
See PortDirection
Declaration
public PortDirection Direction
Field Value
| Type | Description |
|---|---|
| PortDirection |
DisplayName
Name of the port as it appears in the editor.
Declaration
public string DisplayName
Field Value
| Type | Description |
|---|---|
| String |
Extra
See FieldExtra, use this field to describe functionalities of the port.
Declaration
public FieldExtra Extra
Field Value
| Type | Description |
|---|---|
| FieldExtra |
Methods
Extract<T>(String)
Extract a single FieldAttribute from a field.
Declaration
public static FieldAttribute Extract<T>(string fieldName)
Parameters
| Type | Name | Description |
|---|---|---|
| String | fieldName | Name of the field. |
Returns
| Type | Description |
|---|---|
| FieldAttribute | FieldAttribute |
Type Parameters
| Name | Description |
|---|---|
| T | Type to check for the field. |
ExtractAll(Object)
Get all ports from an object.
Declaration
public static List<FieldInfo> ExtractAll(object instance)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | instance | Object to extract from. |
Returns
| Type | Description |
|---|---|
| List<FieldInfo> | List of FieldInfo corresponding to ports on the object. |
ExtractLists(Object)
Get all portlists from an object.
Declaration
public static List<FieldInfo> ExtractLists(object instance)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | instance | Object to extract from. |
Returns
| Type | Description |
|---|---|
| List<FieldInfo> | List of PortList fields. |
IsList(FieldInfo)
Checks if this port is a PortList.
Declaration
public static bool IsList(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | Field to check. |
Returns
| Type | Description |
|---|---|
| Boolean | True if the field is a PortList |