public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { FloatCollection result = new FloatCollection(); string[] values = (value as string).Split(new char[] { ',' }); foreach (string s in values) { result.Add((float)Converter.FromString(typeof(float), s)); } return(result); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Reads a float array from the stream. /// </summary> public FloatCollection ReadFloatArray(string fieldName) { bool isNil = false; FloatCollection values = new FloatCollection(); if (BeginField(fieldName, true, out isNil)) { PushNamespace(Namespaces.OpcUaXsd); while (MoveToElement("Float")) { values.Add(ReadFloat("Float")); } // 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 float array from the stream. /// </summary> public FloatCollection ReadFloatArray(string fieldName) { int length = ReadArrayLength(); if (length == -1) { return null; } FloatCollection values = new FloatCollection(length); for (int ii = 0; ii < length; ii++) { values.Add(ReadFloat(null)); } return values; }
/// <summary> /// Reads a float array from the stream. /// </summary> public FloatCollection ReadFloatArray(string fieldName) { var values = new FloatCollection(); 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(ReadFloat(null)); } finally { m_stack.Pop(); } } return values; }