| 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 |
} |