/// <summary>
        /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
        /// node being created. 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">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 WriteManyNodes <T>(string nodeName, T[] values, WriteManyNodesHandler <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++)
                    {
                        WriteStartNode(null);
                        writeHandler(this, values[i]);
                        WriteEndNode(null);
                    }
                }
            }
            WriteEndNode(nodeName);
        }
        /// <summary>
        /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
        /// node being created. 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 WriteManyNodes <T>(string nodeName, IEnumerable <T> values, WriteManyNodesHandler <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)
                    {
                        WriteStartNode(null);
                        writeHandler(this, value);
                        WriteEndNode(null);
                    }
                }
            }
            WriteEndNode(nodeName);
        }
Example #3
0
        /// <summary>
        /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
        /// node being created. 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">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 WriteManyNodes <T>(string nodeName, T[] values, WriteManyNodesHandler <T> writeHandler)
        {
            int count;

            if (values != null)
            {
                count = values.Length;
            }
            else
            {
                count = 0;
            }

            WriteStartNode(nodeName);
            {
                Write(XmlValueHelper.CountValueKey, count);
                if (values != null && count > 0)
                {
                    for (var i = 0; i < values.Length; i++)
                    {
                        var childNodeName = XmlValueHelper.GetItemKey(i);
                        WriteStartNode(childNodeName);
                        writeHandler(this, values[i]);
                        WriteEndNode(childNodeName);
                    }
                }
            }
            WriteEndNode(nodeName);
        }
Example #4
0
        /// <summary>
        /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
        /// node being created. 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 WriteManyNodes <T>(string nodeName, IEnumerable <T> values, WriteManyNodesHandler <T> writeHandler)
        {
            int count;

            if (values != null)
            {
                count = values.Count();
            }
            else
            {
                count = 0;
            }

            WriteStartNode(nodeName);
            {
                Write("Count", count);
                if (values != null && count > 0)
                {
                    var i = 0;
                    foreach (var value in values)
                    {
                        var childNodeName = XmlValueHelper.GetItemKey(i);
                        WriteStartNode(childNodeName);
                        writeHandler(this, value);
                        WriteEndNode(childNodeName);
                        i++;
                    }
                }
            }
            WriteEndNode(nodeName);
        }
Example #5
0
 /// <summary>
 /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
 /// node being created. 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">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 WriteManyNodes <T>(string nodeName, T[] values, WriteManyNodesHandler <T> writeHandler)
 {
     _writer.WriteManyNodes(nodeName, values, writeHandler);
 }
Example #6
0
 /// <summary>
 /// Writes multiple values of type <typeparamref name="T"/>, where each value will result in its own
 /// node being created. 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 WriteManyNodes <T>(string nodeName, IEnumerable <T> values, WriteManyNodesHandler <T> writeHandler)
 {
     _writer.WriteManyNodes(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">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>
 /// <exception cref="NotSupportedException">This method is not supported by the <see cref="BitStream"/>.</exception>
 void IValueWriter.WriteManyNodes <T>(string nodeName, T[] values, WriteManyNodesHandler <T> writeHandler)
 {
     throw CreateNodesNotSupportedException();
 }