Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Xml / System / Xml / Core / XmlParserContext.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="XmlParserContext.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>                                                                
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
7
8 using System.Xml;
9 using System.Text;
10 using System;
11
12 namespace System.Xml {
13     // Specifies the context that the XmLReader will use for xml fragment
14     public class XmlParserContext {
15     
16         private XmlNameTable            _nt             = null;
17         private XmlNamespaceManager     _nsMgr          = null;
18         private String                  _docTypeName    = String.Empty;
19         private String                  _pubId          = String.Empty;
20         private String                  _sysId          = String.Empty;
21         private String                  _internalSubset = String.Empty;
22         private String                  _xmlLang        = String.Empty;
23         private XmlSpace                _xmlSpace;
24         private String                  _baseURI        = String.Empty;
25         private Encoding                _encoding       = null;
26         
27         public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr,String xmlLang, XmlSpace xmlSpace)
28         : this(nt, nsMgr, null, null, null, null, String.Empty, xmlLang, xmlSpace)
29         {
30             // Intentionally Empty
31         }
32
33         public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr,String xmlLang, XmlSpace xmlSpace, Encoding enc)
34         : this(nt, nsMgr, null, null, null, null, String.Empty, xmlLang, xmlSpace, enc)
35         {
36             // Intentionally Empty
37         }
38
39         public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName,
40                   String pubId, String sysId, String internalSubset, String baseURI,
41                   String xmlLang, XmlSpace xmlSpace) 
42         : this(nt, nsMgr, docTypeName, pubId, sysId, internalSubset, baseURI, xmlLang, xmlSpace, null)
43         {
44             // Intentionally Empty
45         }
46         
47         public XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, String docTypeName,
48                           String pubId, String sysId, String internalSubset, String baseURI,
49                           String xmlLang, XmlSpace xmlSpace, Encoding enc)
50         {
51             
52             if (nsMgr != null) {
53                 if (nt == null) {
54                     _nt = nsMgr.NameTable;
55                 }
56                 else {
57                     if ( (object)nt != (object)  nsMgr.NameTable ) {
58                         throw new XmlException(Res.Xml_NotSameNametable, string.Empty);
59                     }
60                     _nt = nt;
61                 }
62             }
63             else {
64                 _nt = nt;
65             }
66             
67             _nsMgr              = nsMgr;
68             _docTypeName        = (null == docTypeName ? String.Empty : docTypeName);
69             _pubId              = (null == pubId ? String.Empty : pubId);
70             _sysId              = (null == sysId ? String.Empty : sysId);
71             _internalSubset     = (null == internalSubset ? String.Empty : internalSubset);
72             _baseURI            = (null == baseURI ? String.Empty : baseURI);
73             _xmlLang            = (null == xmlLang ? String.Empty : xmlLang);
74             _xmlSpace           = xmlSpace;
75             _encoding           = enc;
76             
77         }
78
79         public XmlNameTable NameTable {
80             get {
81                 return _nt;            
82             }
83             set {
84                 _nt = value;
85             }            
86         }
87
88         public XmlNamespaceManager  NamespaceManager {
89             get {
90                 return _nsMgr;            
91             }
92             set {
93                 _nsMgr = value;
94             }            
95         }
96
97         public String  DocTypeName {
98             get {
99                 return _docTypeName;            
100             }
101             set {
102                 _docTypeName = (null == value ? String.Empty : value);
103             }            
104         }
105
106         public String PublicId {
107             get {
108                 return _pubId;            
109             }
110             set {
111                 _pubId = (null == value ? String.Empty : value);
112             }            
113         }
114
115         public String SystemId {
116             get {
117                 return _sysId;       
118             }
119             set {
120                 _sysId = (null == value ? String.Empty : value);
121             }            
122         }
123
124         public String BaseURI {
125             get {
126                 return _baseURI;       
127             }
128             set {
129                 _baseURI = (null == value ? String.Empty : value);
130             }            
131         }
132
133         public String InternalSubset {
134             get {
135                 return _internalSubset;       
136             }
137             set {
138                 _internalSubset = (null == value ? String.Empty : value);
139             }            
140         }
141
142         public String XmlLang {
143             get {
144                 return _xmlLang;       
145             }
146             set {
147                 _xmlLang = (null == value ? String.Empty : value);
148             }            
149         }
150
151         public XmlSpace XmlSpace {
152             get {
153                 return _xmlSpace;       
154             }
155             set {
156                 _xmlSpace = value;
157             }            
158         }
159
160         public Encoding Encoding {
161             get {
162                 return _encoding;       
163             }
164             set {
165                 _encoding = value;
166             }            
167         }
168
169         internal bool HasDtdInfo {
170             get {
171                 return ( _internalSubset != string.Empty || _pubId != string.Empty || _sysId != string.Empty );
172             }
173         }
174
175     } // class XmlContext
176 } // namespace System.Xml
177     
178     
179