} // Read public static unsafe uint Read(this NativeReader reader, uint offset, out SByteCollection values) { values = new SByteCollection(reader, offset); uint count; offset = reader.DecodeUnsigned(offset, out count); offset = checked(offset + count * sizeof(SByte)); return offset; } // Read
} // Read public static unsafe uint Read(this NativeReader reader, uint offset, out SByteCollection values) { values = new SByteCollection(reader, offset); uint count; offset = reader.DecodeUnsigned(offset, out count); offset = checked (offset + count * sizeof(SByte)); return(offset); } // Read
public static sbyte[] ToArray(this SByteCollection collection, Type enumType = null) { int count = collection.Count; sbyte[] result; if (enumType != null) { Debug.Assert(enumType.IsEnum); result = (sbyte[])Array.CreateInstance(enumType, count); } else { result = new sbyte[count]; } int i = 0; foreach (sbyte element in collection) { result[i++] = element; } Debug.Assert(i == count); return(result); }
/// <summary> /// Reads a sbyte array from the stream. /// </summary> public SByteCollection ReadSByteArray(string fieldName) { bool isNil = false; SByteCollection values = new SByteCollection(); if (BeginField(fieldName, true, out isNil)) { PushNamespace(Namespaces.OpcUaXsd); while (MoveToElement("SByte")) { values.Add(ReadSByte("SByte")); } // check the length. if (m_context.MaxArrayLength > 0 && m_context.MaxArrayLength < values.Count) { throw new ServiceResultException(StatusCodes.BadEncodingLimitsExceeded); } PopNamespace(); EndField(fieldName); return values; } if (isNil) { return null; } return values; }
/// <summary> /// Reads a sbyte array from the stream. /// </summary> public SByteCollection ReadSByteArray(string fieldName) { int length = ReadArrayLength(); if (length == -1) { return null; } SByteCollection values = new SByteCollection(length); for (int ii = 0; ii < length; ii++) { values.Add(ReadSByte(null)); } return values; }
/// <summary> /// Reads a sbyte array from the stream. /// </summary> public SByteCollection ReadSByteArray(string fieldName) { var values = new SByteCollection(); List<object> token = null; if (!ReadArrayField(fieldName, out token)) { return values; } for (int ii = 0; ii < token.Count; ii++) { try { m_stack.Push(token[ii]); values.Add(ReadSByte(null)); } finally { m_stack.Pop(); } } return values; }