public static int LocalToRemoteValue(Variant srcValue, out object dstValue)
{
dstValue = null;
TypeInfo srcType = srcValue.TypeInfo;
if (srcType == null)
{
srcType = TypeInfo.Construct(srcValue.Value);
}
if (srcType.BuiltInType <= BuiltInType.DateTime
|| srcType.BuiltInType == BuiltInType.ByteString) // OPC UA specification ver 1.02 compliant.
{
dstValue = srcValue.Value;
return ResultIds.S_OK;
}
try
{
if (srcType.BuiltInType == BuiltInType.Variant && srcType.ValueRank >= 0)
{
dstValue = TypeInfo.CastArray((Array)srcValue.Value, BuiltInType.Variant, BuiltInType.Null, LocalToRemoteValue);
return ResultIds.S_OK;
}
}
catch (Exception)
{
return ResultIds.E_BADTYPE;
}
return ResultIds.E_BADTYPE;
}