Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data.SqlXml / System / Xml / Xsl / XsltOld / InputScope.cs
blob66b85807e711154b69eaf5f8599821f4fabab4f7
1 //------------------------------------------------------------------------------
2 // <copyright file="InputScope.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">Microsoft</owner>
6 //------------------------------------------------------------------------------
8 namespace System.Xml.Xsl.XsltOld {
9 using Res = System.Xml.Utils.Res;
10 using System;
11 using System.Diagnostics;
12 using System.Xml;
13 using System.Xml.XPath;
14 using System.Collections;
16 internal class InputScope : DocumentScope {
17 private InputScope parent;
18 private bool forwardCompatibility;
19 private bool canHaveApplyImports;
20 private Hashtable variables;
21 private Hashtable extensionNamespaces;
22 private Hashtable excludedNamespaces;
24 internal InputScope Parent {
25 get { return this.parent; }
28 internal Hashtable Variables {
29 get { return this.variables; }
32 internal bool ForwardCompatibility {
33 get { return this.forwardCompatibility; }
34 set { this.forwardCompatibility = value; }
37 internal bool CanHaveApplyImports {
38 get { return this.canHaveApplyImports; }
39 set { this.canHaveApplyImports = value; }
42 internal InputScope(InputScope parent) {
43 Init(parent);
46 internal void Init(InputScope parent) {
47 this.scopes = null;
48 this.parent = parent;
50 if (this.parent != null) {
51 this.forwardCompatibility = this.parent.forwardCompatibility;
52 this.canHaveApplyImports = this.parent.canHaveApplyImports;
56 internal void InsertExtensionNamespace(String nspace) {
57 if (this.extensionNamespaces == null ) {
58 this.extensionNamespaces = new Hashtable();
60 this.extensionNamespaces[nspace] = null;
63 internal bool IsExtensionNamespace(String nspace) {
64 if (extensionNamespaces == null ) {
65 return false;
67 return extensionNamespaces.Contains(nspace);
70 internal void InsertExcludedNamespace(String nspace) {
71 if (this.excludedNamespaces == null ) {
72 this.excludedNamespaces = new Hashtable();
74 this.excludedNamespaces[nspace] = null;
77 internal bool IsExcludedNamespace(String nspace) {
78 if (excludedNamespaces == null ) {
79 return false;
81 return excludedNamespaces.Contains(nspace);
84 internal void InsertVariable(VariableAction variable) {
85 Debug.Assert(variable != null);
87 if (this.variables == null) {
88 this.variables = new Hashtable();
90 this.variables[variable.Name] = variable;
93 internal int GetVeriablesCount() {
94 if (this.variables == null) {
95 return 0;
97 return this.variables.Count;
100 public VariableAction ResolveVariable(XmlQualifiedName qname) {
101 for (InputScope inputScope = this; inputScope != null; inputScope = inputScope.Parent) {
102 if (inputScope.Variables != null) {
103 VariableAction variable = (VariableAction) inputScope.Variables[qname];
104 if(variable != null) {
105 return variable;
109 return null;
112 public VariableAction ResolveGlobalVariable(XmlQualifiedName qname) {
113 InputScope prevScope = null;
114 for (InputScope inputScope = this; inputScope != null; inputScope = inputScope.Parent) {
115 prevScope = inputScope;
117 return prevScope.ResolveVariable(qname);