private Matrix ReadMatrix(string fieldName)
{
Array elements = null;
Int32Collection dimensions = null;
TypeInfo typeInfo = null;
if (BeginField(fieldName, true))
{
PushNamespace(Namespaces.OpcUaXsd);
if (BeginField("Elements", true))
{
object contents = ReadVariantContents(out typeInfo);
elements = contents as Array;
EndField("Elements");
}
dimensions = ReadInt32Array("Dimensions");
PopNamespace();
EndField(fieldName);
}
if (elements == null)
{
throw new ServiceResultException(StatusCodes.BadDecodingError, "The Matrix contains invalid elements");
}
if (dimensions != null && dimensions.Count > 0)
{
return new Matrix(elements, typeInfo.BuiltInType, dimensions.ToArray());
}
return new Matrix(elements, typeInfo.BuiltInType);
}