Support for creating a Type Library of custom Structures
In v3.0, we ask that you mark the assembly containing your custom structures with TypeLibrary() attribute.
The Encoder/Decoder will discover these custom structures and be able to read and write these structures with the server.
using System;
using Workstation.ServiceModel.Ua;
[assembly: TypeLibrary()]
namespace CustomTypeLibrary
{
[DataTypeId("nsu=http://www.unifiedautomation.com/DemoServer/;i=3002")]
[BinaryEncodingId("nsu=http://www.unifiedautomation.com/DemoServer/;i=5054")]
public class CustomVector : Structure
{
public double X { get; set; }
public double Y { get; set; }
public double Z { get; set; }
public override void Encode(IEncoder encoder)
{
encoder.WriteDouble("X", X);
encoder.WriteDouble("Y", Y);
encoder.WriteDouble("Z", Z);
}
public override void Decode(IDecoder decoder)
{
X = decoder.ReadDouble("X");
Y = decoder.ReadDouble("Y");
Z = decoder.ReadDouble("Z");
}
}
}