1 // mono writer-method-gen.exe > System.Xml/XmlDictionaryWriterAutoGen.cs
3 using System.Globalization;
5 using System.CodeDom.Compiler;
6 using Microsoft.CSharp;
10 public static void Main ()
12 Console.Out.NewLine = "\n";
13 Type [] types = new Type [] {
14 typeof (bool), typeof (DateTime), typeof (decimal), typeof (double),
15 typeof (Guid), typeof (short), typeof (int), typeof (long), typeof (float), typeof (TimeSpan) };
22 public abstract partial class XmlDictionaryWriter : XmlWriter
24 void CheckWriteArrayArguments (Array array, int offset, int length)
27 throw new ArgumentNullException (""array"");
29 throw new ArgumentOutOfRangeException (""offset is negative"");
30 if (offset > array.Length)
31 throw new ArgumentOutOfRangeException (""offset exceeds the length of the destination array"");
33 throw new ArgumentOutOfRangeException (""length is negative"");
34 if (length > array.Length - offset)
35 throw new ArgumentOutOfRangeException (""length + offset exceeds the length of the destination array"");
38 void CheckDictionaryStringArgs (XmlDictionaryString localName, XmlDictionaryString namespaceUri)
40 if (localName == null)
41 throw new ArgumentNullException (""localName"");
42 if (namespaceUri == null)
43 throw new ArgumentNullException (""namespaceUri"");
47 foreach (Type type in types) {
49 public virtual void WriteArray (string prefix, XmlDictionaryString localName, XmlDictionaryString namespaceUri, {0} [] array, int offset, int length)
51 CheckDictionaryStringArgs (localName, namespaceUri);
52 WriteArray (prefix, localName.Value, namespaceUri.Value, array, offset, length);
55 public virtual void WriteArray (string prefix, string localName, string namespaceUri, {0} [] array, int offset, int length)
57 CheckWriteArrayArguments (array, offset, length);
58 for (int i = 0; i < length; i++) {{
59 WriteStartElement (prefix, localName, namespaceUri);
60 WriteValue (array [offset + i]);
64 }}", ToCSharp (type), type.Name);
72 static CodeDomProvider cs = new CSharpCodeProvider ();
74 static string ToCSharp (Type type)
76 string r = cs.GetTypeOutput (new CodeTypeReference (type));
77 return r != type.FullName ? r : type.Name;