File: DelegatingConfigHost.cs

package info (click to toggle)
mono 6.12.0.199%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,296,836 kB
  • sloc: cs: 11,181,803; xml: 2,850,076; ansic: 699,709; cpp: 123,344; perl: 59,361; javascript: 30,841; asm: 21,853; makefile: 20,405; sh: 15,009; python: 4,839; pascal: 925; sql: 859; sed: 16; php: 1
file content (256 lines) | stat: -rw-r--r-- 10,412 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
//------------------------------------------------------------------------------
// <copyright file="DelegatingConfigHost.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Configuration.Internal {
    using System.Configuration;
    using System.IO;
    using System.Security.Permissions;
    using System.Reflection;
    using System.Threading;
    using System.Security;
    using System.CodeDom.Compiler;
    using System.Xml;

    //
    // A public implementation of IInternalConfigHost that simply 
    // delegates all members of the IInternalConfigHost interface to 
    // another instance of a host. All interface members are marked virtual
    // so that a derived class can override just the ones needed to
    // implement that specific host, while all others are delegated to
    // another implementation such as InternalConfigHost.
    //
    // The advantages of this arrangement are:
    //  * The IInternalConfigHost interface can be extended without
    //    requiring other hosts to be updated.
    //  * This class that we are making public has no implementation
    //    of its own that can be exploited. All the hosts with meaningful
    //    implementation can remain internal.
    //  * It allows straightforward chaining of host functionality,
    //    see UpdateConfigHost as an example.
    //
    public class DelegatingConfigHost : IInternalConfigHost, IInternalConfigurationBuilderHost {
        IInternalConfigHost _host;
        IInternalConfigurationBuilderHost _configBuilderHost;

        protected DelegatingConfigHost() {}

        // The host that is delegated to.
        protected IInternalConfigHost Host {
            get {return _host;}
            set {
                _host = value;
                _configBuilderHost = _host as IInternalConfigurationBuilderHost;
            }
        }

        protected IInternalConfigurationBuilderHost ConfigBuilderHost {
            get { return _configBuilderHost; }
        }

        public virtual void Init(IInternalConfigRoot configRoot, params object[] hostInitParams) {
            Host.Init(configRoot, hostInitParams);
        }

        public virtual void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, 
                IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams) {

            Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams);
        }

        public virtual bool IsConfigRecordRequired(string configPath) {
            return Host.IsConfigRecordRequired(configPath);
        }

        public virtual bool IsInitDelayed(IInternalConfigRecord configRecord) {
            return Host.IsInitDelayed(configRecord);
        }

        public virtual void RequireCompleteInit(IInternalConfigRecord configRecord) {
            Host.RequireCompleteInit(configRecord);
        }

        // IsSecondaryRoot
        //
        // Is this a secondary root.  This means that it is a node in which
        // everything that is defined in it should also be treated as a root.
        // So...if a factory record is defined that was already defined above
        // then throw since it is not allowed.
        //
        public virtual bool IsSecondaryRoot(string configPath) {
            return Host.IsSecondaryRoot(configPath);
        }

        public virtual string GetStreamName(string configPath) {
            return Host.GetStreamName(configPath);
        }

        public virtual string GetStreamNameForConfigSource(string streamName, string configSource) {
            return Host.GetStreamNameForConfigSource(streamName, configSource);
        }

        public virtual object GetStreamVersion(string streamName) {
            return Host.GetStreamVersion(streamName);
        }

        public virtual Stream OpenStreamForRead(string streamName) {
            return Host.OpenStreamForRead(streamName);
        }

        public virtual Stream OpenStreamForRead(string streamName, bool assertPermissions) {
            return Host.OpenStreamForRead(streamName, assertPermissions);
        }

        public virtual Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext) {
            return Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext);
        }

        public virtual Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext, bool assertPermissions) {
            return Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext, assertPermissions);
        }

        public virtual void WriteCompleted(string streamName, bool success, object writeContext) {
            Host.WriteCompleted(streamName, success, writeContext);
        }

        public virtual void WriteCompleted(string streamName, bool success, object writeContext, bool assertPermissions) {
            Host.WriteCompleted(streamName, success, writeContext, assertPermissions);
        }

        public virtual void DeleteStream(string streamName) {
            Host.DeleteStream(streamName);
        }

        public virtual bool IsFile(string streamName) {
            return Host.IsFile(streamName);
        }

        public virtual bool SupportsChangeNotifications {
            get {
                return Host.SupportsChangeNotifications;
            }
        }

        public virtual object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback) {
            return Host.StartMonitoringStreamForChanges(streamName, callback);
        }

        public virtual void StopMonitoringStreamForChanges(string streamName, StreamChangeCallback callback) {
            Host.StopMonitoringStreamForChanges(streamName, callback);
        }

        public virtual bool SupportsRefresh {
            get {
                return Host.SupportsRefresh;
            }
        }

        public virtual bool SupportsPath {
            get {
                return Host.SupportsPath;
            }
        }

        public virtual bool SupportsLocation {
            get {
                return Host.SupportsLocation;
            }
        }

        public virtual bool IsAboveApplication(string configPath) {
            return Host.IsAboveApplication(configPath);
        }

        public virtual bool IsDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition) {
            return Host.IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition);
        }

        public virtual void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo) {
            Host.VerifyDefinitionAllowed(configPath, allowDefinition, allowExeDefinition, errorInfo);
        }

        public virtual string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath) {
            return Host.GetConfigPathFromLocationSubPath(configPath, locationSubPath);
        }

        public virtual bool IsLocationApplicable(string configPath) {
            return Host.IsLocationApplicable(configPath);
        }

        public virtual bool IsTrustedConfigPath(string configPath) {
            return Host.IsTrustedConfigPath(configPath);
        }

        public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord) {
            return Host.IsFullTrustSectionWithoutAptcaAllowed(configRecord);
        }

        public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady) {
            Host.GetRestrictedPermissions(configRecord, out permissionSet, out isHostReady);
        }

        public virtual IDisposable Impersonate() {
            return Host.Impersonate();
        }

        public virtual bool PrefetchAll(string configPath, string streamName) {
            return Host.PrefetchAll(configPath, streamName);
        }

        public virtual bool PrefetchSection(string sectionGroupName, string sectionName) {
            return Host.PrefetchSection(sectionGroupName, sectionName);
        }

        public virtual object CreateDeprecatedConfigContext(string configPath) {
            return Host.CreateDeprecatedConfigContext(configPath);
        }

        public virtual object 
        CreateConfigurationContext( string configPath, string locationSubPath ) 
        {
            return Host.CreateConfigurationContext( configPath, locationSubPath );
        }

        public virtual string DecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) {
            return Host.DecryptSection(encryptedXml, protectionProvider, protectedConfigSection);
        }

        public virtual string EncryptSection(string clearTextXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection) {
            return Host.EncryptSection(clearTextXml, protectionProvider, protectedConfigSection);
        }

        public virtual Type GetConfigType(string typeName, bool throwOnError) {
            return Host.GetConfigType(typeName, throwOnError);
        }

        public virtual string GetConfigTypeName(Type t) {
            return Host.GetConfigTypeName(t);
        }

        public virtual bool IsRemote {
            get {
                return Host.IsRemote;
            }
        }

        public virtual XmlNode ProcessRawXml(XmlNode rawXml, ConfigurationBuilder builder) {
            if (ConfigBuilderHost != null) {
                return ConfigBuilderHost.ProcessRawXml(rawXml, builder);
            }

            return rawXml;
        }

        public virtual ConfigurationSection ProcessConfigurationSection(ConfigurationSection configSection, ConfigurationBuilder builder) {
            if (ConfigBuilderHost != null) {
                return ConfigBuilderHost.ProcessConfigurationSection(configSection, builder);
            }

            return configSection;
        }

    }
}