ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/OniSplit/Xml/XmlWriterExtensions.cs
Revision: 1114
Committed: Wed Jan 22 14:08:57 2020 UTC (5 years, 8 months ago) by iritscen
File size: 822 byte(s)
Log Message:
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File Contents

# Content
1 using System;
2 using System.Text;
3 using System.Xml;
4
5 namespace Oni.Xml
6 {
7 internal static class XmlWriterExtensions
8 {
9 public static void WriteFloatArray(this XmlWriter writer, float[] array)
10 {
11 writer.WriteArray(array, XmlConvert.ToString);
12 }
13
14 public static void WriteArray<T>(this XmlWriter writer, T[] array, Func<T, string> converter)
15 {
16 var text = new StringBuilder(array.Length * 8);
17
18 for (int i = 0; i < array.Length; i++)
19 {
20 if (i != array.Length - 1)
21 text.AppendFormat("{0} ", converter(array[i]));
22 else
23 text.Append(converter(array[i]));
24 }
25
26 writer.WriteValue(text.ToString());
27 }
28 }
29 }