DynamicValue Class

Dynamic value (uses RuntimeBinding for ISymbol value reading / writing).

Inheritance Hierarchy

SystemObject
  System.DynamicDynamicObject
    TwinCAT.TypeSystemDynamicValue
      TwinCAT.TypeSystemDynamicArrayValue
      TwinCAT.TypeSystemDynamicEnumValue
      TwinCAT.TypeSystemDynamicPointerValue
      TwinCAT.TypeSystemDynamicReferenceValue

Namespace: TwinCAT.TypeSystem
Assembly: TwinCAT.Ads (in TwinCAT.Ads.dll) Version: 7.0.0+e56d35ccc4675faac24789a4aab60071fc61d470

Syntax

C#

public class DynamicValue : DynamicObject, 
    IDynamicValue, IDynamicMetaObjectProvider, IValue, IStructValue, IArrayValue

The DynamicValue type exposes the following members.

Properties

 

Name

Description

DynamicValue Class 1:

Age

Gets the age of the value (last successful read of the value)

DynamicValue Class 2:

CachedRaw

Gets the cached Raw internal Data.

DynamicValue Class 3:

CachedRawStatic

Gets the value of the cached field values

DynamicValue Class 4:

DataType

Gets the data type bound to this IValue

DynamicValue Class 5:

IsPrimitive

Gets a value indicating whether this IValue is a primitive value.

DynamicValue Class 6:

Logger

Gets the logger object

DynamicValue Class 7:

ParentValue

Gets the parent value.

DynamicValue Class 8:

ResolvedType

Gets the resolved type.

DynamicValue Class 9:

Symbol

Gets the symbol that is bound to this value.

DynamicValue Class 10:

TimeStamp

Gets the Time stamp of the last successful read of the Value.

DynamicValue Class 11:

UpdateMode

Gets / Sets the update mode

DynamicValue Class 12:

ValueFactory

The value factory

Methods

 

Name

Description

DynamicValue Class 13:

CanLog

Determines whether the used logger is enabled for the specified log level.

DynamicValue Class 14:

Equals

Determines whether the specified object is equal to the current object.
(Inherited from Object)

DynamicValue Class 15:

Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)

DynamicValue Class 16:

GetDynamicMemberNames

Returns the enumeration of all dynamic member names.
(Overrides DynamicObjectGetDynamicMemberNames)

DynamicValue Class 17:

GetHashCode

Serves as the default hash function.
(Inherited from Object)

DynamicValue Class 18:

GetMetaObject

Provides a DynamicMetaObject that dispatches to the dynamic virtual methods. The object can be encapsulated inside another DynamicMetaObject to provide custom behavior for individual actions. This method supports the Dynamic Language Runtime infrastructure for language implementers and it is not intended to be used directly from your code.
(Inherited from DynamicObject)

DynamicValue Class 19:

GetType

Gets the Type of the current instance.
(Inherited from Object)

DynamicValue Class 20:

MemberwiseClone

Creates a shallow copy of the current Object.
(Inherited from Object)

DynamicValue Class 21:

Read

Reads the value (via ADS)

DynamicValue Class 22:

ReadAsync

read as an asynchronous operation.

DynamicValue Class 23:

ResolveValue

Resolves the Value object to its primitive value.

DynamicValue Class 24:

setMemberValue

Writes the specified member element.

DynamicValue Class 25:

ToString

Returns a String that represents this instance.
(Overrides ObjectToString)

DynamicValue Class 26:

TryBinaryOperation

Provides implementation for binary operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as addition and multiplication.
(Inherited from DynamicObject)

DynamicValue Class 27:

TryConvert

Provides implementation for type conversion operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations that convert an object from one type to another.
(Overrides DynamicObjectTryConvert(ConvertBinder, Object))

DynamicValue Class 28:

TryCreateInstance

Provides the implementation for operations that initialize a new instance of a dynamic object. This method is not intended for use in C# or Visual Basic.
(Inherited from DynamicObject)

DynamicValue Class 29:

TryDeleteIndex

Provides the implementation for operations that delete an object by index. This method is not intended for use in C# or Visual Basic.
(Inherited from DynamicObject)

DynamicValue Class 30:

TryDeleteMember

Provides the implementation for operations that delete an object member. This method is not intended for use in C# or Visual Basic.
(Inherited from DynamicObject)

DynamicValue Class 31:

TryGetArrayElementValues

Returns Array Element values.

DynamicValue Class 32:

TryGetIndex

Provides the implementation for operations that get a value by index. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for indexing operations.
(Overrides DynamicObjectTryGetIndex(GetIndexBinder, Object, Object))

DynamicValue Class 33:

TryGetIndexValue(Int32, Object)

Reads the specified array element.

DynamicValue Class 34:

TryGetIndexValue(Object, Object)

Tries the get index value.

DynamicValue Class 35:

TryGetMember

Provides the implementation for operations that get member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as getting a value for a property.
(Overrides DynamicObjectTryGetMember(GetMemberBinder, Object))

DynamicValue Class 36:

TryGetMemberValue

Tries the get member value.

DynamicValue Class 37:

TryInvoke

Provides the implementation for operations that invoke an object. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as invoking an object or a delegate.
(Overrides DynamicObjectTryInvoke(InvokeBinder, Object, Object))

DynamicValue Class 38:

TryInvokeMember

Provides the implementation for operations that invoke a member. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as calling a method.
(Overrides DynamicObjectTryInvokeMember(InvokeMemberBinder, Object, Object))

DynamicValue Class 39:

TryResolveValue

Tries to resolves the Value object to its primitive value.

DynamicValue Class 40:

TrySetIndex

Provides the implementation for operations that set a value by index. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations that access objects by a specified index.
(Overrides DynamicObjectTrySetIndex(SetIndexBinder, Object, Object))

DynamicValue Class 41:

TrySetIndexValue(Int32, Object)

Tries to set the indexed value on Arrays

DynamicValue Class 42:

TrySetIndexValue(Object, Object)

Tries to set the indexed value on Arrays

DynamicValue Class 43:

TrySetMember

Provides the implementation for operations that set member values. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as setting a value for a property.
(Overrides DynamicObjectTrySetMember(SetMemberBinder, Object))

DynamicValue Class 44:

TrySetMemberValue

Tries to Set a Member/Property Value

DynamicValue Class 45:

TryUnaryOperation

Provides implementation for unary operations. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as negation, increment, or decrement.
(Inherited from DynamicObject)

DynamicValue Class 46:

Write

Writes the value (via ADS)

DynamicValue Class 47:

WriteAsync

write as an asynchronous operation.

Fields

 

Name

Description

cachedRaw

The cached (raw) data) of the Root Symbol

cachedRawStatic

The cached raw static value

Remarks

The DynamicValue adds dynamic run time behaviour to the IValueValue/IValue. That means e.g. for struct values that .NET Properties are on-the-fly defined and dispatched at runtime just like defined in the structs structs data type definition. Another example is the access of Array Element values through indexes.

Example

Sample for the dynamic resolution of Symbols and reading values:

Dynamic Symbol access

/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
static async void Main(string[] args)
{
    // Get the AdsAddress from command-line arguments
    AmsAddress address = ArgParser.Parse(args);

    CancellationTokenSource cancelSource = new CancellationTokenSource();
    CancellationToken cancel = cancelSource.Token;

    using (AdsClient client = new AdsClient())
    {
    // Connect to the target device
    client.Connect(address);

    // Usage of "dynamic" Type and Symbols (>= .NET4 only)
    SymbolLoaderSettings settings = new SymbolLoaderSettings(SymbolsLoadMode.DynamicTree);
    IAdsSymbolLoader dynLoader = (IAdsSymbolLoader)SymbolLoaderFactory.Create(client, settings);

Reference

TwinCAT.TypeSystem Namespace DynamicSymbol DynamicObject IValue

Beckhoff Automation GmbH & Co. KG 2001-2026