Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / Dom / XmlDomTextWriter.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="XmlDomTextWriter.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">[....]</owner>
6 //------------------------------------------------------------------------------
7
8 namespace System.Xml {
9
10     using System;
11     using System.IO;
12     using System.Text;
13     using System.Runtime.Versioning;
14
15     // Represents a writer that will make it possible to work with prefixes even
16     // if the namespace is not specified.
17     // This is not possible with XmlTextWriter. But this class inherits XmlTextWriter.
18     internal class XmlDOMTextWriter : XmlTextWriter {
19
20         public XmlDOMTextWriter( Stream w, Encoding encoding ) : base( w,encoding ) {
21         }
22
23         [ResourceConsumption(ResourceScope.Machine)]
24         [ResourceExposure(ResourceScope.Machine)]
25         public XmlDOMTextWriter( String filename, Encoding encoding ) : base( filename,encoding ){
26         }
27
28         public XmlDOMTextWriter( TextWriter w ) : base( w ){
29         }
30
31         // Overrides the baseclass implementation so that emptystring prefixes do
32         // do not fail if namespace is not specified.
33         public override void WriteStartElement( string prefix, string localName, string ns ){
34             if( ( ns.Length == 0 ) && ( prefix.Length != 0 ) )
35                 prefix = "" ;
36
37             base.WriteStartElement( prefix, localName, ns );
38         }
39
40         // Overrides the baseclass implementation so that emptystring prefixes do
41         // do not fail if namespace is not specified.
42         public override  void WriteStartAttribute( string prefix, string localName, string ns ){
43             if( ( ns.Length == 0 ) && ( prefix.Length != 0 )  )
44                 prefix = "" ;
45
46             base.WriteStartAttribute( prefix, localName, ns );
47         }
48     }
49 }
50     
51
52