/// <summary> /// Writes multiple values of the same type to the IValueWriter all under the same node name. /// Unlike the WriteMany for IEnumerables, this guarentees that ordering will be preserved. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Unused by the <see cref="BinaryValueWriter"/>.</param> /// <param name="values">Array of values to write. If this value is null, it will be treated /// the same as if it were an empty array.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> public void WriteMany <T>(string nodeName, T[] values, WriteManyHandler <T> writeHandler) { int count; if (values != null) { count = values.Length; } else { count = 0; } WriteStartNode(nodeName); { Write(null, count); if (values != null && count > 0) { for (var i = 0; i < values.Length; i++) { writeHandler(null, values[i]); } } } WriteEndNode(nodeName); }
/// <summary> /// Writes multiple values of the same type to the IValueWriter all under the same node name. /// Ordering is not guarenteed. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Unused by the BinaryValueWriter.</param> /// <param name="values">IEnumerable of values to write. If this value is null, it will be treated /// the same as if it were an empty IEnumerable.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> public void WriteMany <T>(string nodeName, IEnumerable <T> values, WriteManyHandler <T> writeHandler) { int count; if (values != null) { count = values.Count(); } else { count = 0; } WriteStartNode(nodeName); { Write(null, count); if (values != null && count > 0) { foreach (var value in values) { writeHandler(null, value); } } } WriteEndNode(nodeName); }
/// <summary> /// Writes multiple values of the same type to the IValueWriter all under the same node name. /// Ordering is not guarenteed. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Name of the node that will contain the values.</param> /// <param name="values">IEnumerable of values to write. If this value is null, it will be treated /// the same as if it were an empty IEnumerable.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> public void WriteMany <T>(string nodeName, IEnumerable <T> values, WriteManyHandler <T> writeHandler) { int count; if (values != null) { count = values.Count(); } else { count = 0; } WriteStartNode(nodeName); { Write(XmlValueHelper.CountValueKey, count); if (values != null && count > 0) { var i = 0; foreach (var value in values) { writeHandler(XmlValueHelper.GetItemKey(i), value); i++; } } } WriteEndNode(nodeName); }
/// <summary> /// Writes multiple values of the same type to the IValueWriter all under the same node name. /// Unlike the WriteMany for IEnumerables, this guarentees that ordering will be preserved. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Name of the node that will contain the values.</param> /// <param name="values">Array of values to write. If this value is null, it will be treated /// the same as if it were an empty array.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> public void WriteMany <T>(string nodeName, T[] values, WriteManyHandler <T> writeHandler) { _writer.WriteMany(nodeName, values, writeHandler); }
/// <summary> /// Writes multiple values of the same type to the IValueWriter all under the same node name. /// Ordering is not guarenteed. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Name of the node that will contain the values.</param> /// <param name="values">IEnumerable of values to write. If this value is null, it will be treated /// the same as if it were an empty IEnumerable.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> public void WriteMany <T>(string nodeName, IEnumerable <T> values, WriteManyHandler <T> writeHandler) { _writer.WriteMany(nodeName, values, writeHandler); }
/// <summary> /// Unsupported by the BitStream. /// </summary> /// <typeparam name="T">The Type of value to write.</typeparam> /// <param name="nodeName">Unused by the BitStream.</param> /// <param name="values">Array of values to write. If this value is null, it will be treated /// the same as if it were an empty array.</param> /// <param name="writeHandler">Delegate that writes the value to the IValueWriter.</param> /// <exception cref="NotSupportedException">This method is not supported by the <see cref="BitStream"/>.</exception> void IValueWriter.WriteMany <T>(string nodeName, T[] values, WriteManyHandler <T> writeHandler) { throw CreateNodesNotSupportedException(); }