You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
SMDiagnostics
System
System.Activities
System.Activities.Core.Presentation
System.Activities.DurableInstancing
System.Activities.Presentation
System.ComponentModel.DataAnnotations
System.Configuration
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.IdentityModel
System.IdentityModel.Selectors
System.Net
System.Numerics
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Serialization
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
Abstractions
Administration
Cache
Compilation
Configuration
Internal
AdapterDictionary.cs
AnonymousIdentificationSection.cs
AssemblyCollection.cs
AssemblyInfo.cs
AsyncPreloadModeFlags.cs
AuthenticationConfig.cs
AuthenticationMode.cs
AuthenticationSection.cs
AuthorizationRule.cs
AuthorizationRuleAction.cs
AuthorizationRuleCollection.cs
AuthorizationSection.cs
BrowserCapabilitiesCodeGenerator.cs
BrowserCapabilitiesFactory.cs.REMOVED.git-id
BrowserCapabilitiesFactory35.cs
BrowserCapabilitiesFactoryBase.cs
BrowserCapsElementType.cs
BrowserDefinition.cs
BrowserDefinitionCollection.cs
BrowserTree.cs
BufferModeSettings.cs
BufferModesCollection.cs
BuildProvider.cs
BuildProviderCollection.cs
COAUTHIDENTITY.cs
COAUTHINFO.cs
COSERVERINFO.cs
CacheSection.cs
CapabilitiesAssignment.cs
CapabilitiesPattern.cs
CapabilitiesRule.cs
CapabilitiesSection.cs
CapabilitiesState.cs
CapabilitiesUse.cs
CheckPair.cs
ClientRuntimeConfig.cs
ClientTarget.cs
ClientTargetCollection.cs
ClientTargetSection.cs
ClsCtx.cs
CodeSubDirectoriesCollection.cs
CodeSubDirectory.cs
CompilationSection.cs
Compiler.cs
CompilerCollection.cs
ConfigUtil.cs
ConfigsHelper.cs
CustomError.cs
CustomErrorCollection.cs
CustomErrorsMode.cs
CustomErrorsRedirectMode.cs
CustomErrorsSection.cs
CustomWebEventKey.cs
DelayedRegex.cs
DeploymentSection.cs
ErrorRuntimeConfig.cs
EventMappingSettings.cs
EventMappingSettingsCollection.cs
ExpressServerConfig.cs
ExpressionBuilder.cs
ExpressionBuilderCollection.cs
FcnMode.cs
FileDetails.cs
FolderLevelBuildProvider.cs
FolderLevelBuildProviderCollection.cs
FormsAuthPasswordFormat.cs
FormsAuthenticationConfiguration.cs
FormsAuthenticationCredentials.cs
FormsAuthenticationUser.cs
FormsAuthenticationUserCollection.cs
FormsProtectionEnum.cs
FragmentCacheProfile.cs
FragmentCacheProfileCollection.cs
FullTrustAssembliesSection.cs
FullTrustAssembly.cs
FullTrustAssemblyCollection.cs
GacUtil.cs
GatewayDefinition.cs
GlobalizationSection.cs
HandlerBase.cs
HandlerFactoryCache.cs
HandlerFactoryWrapper.cs
HandlerMappingMemo.cs
HandlerWithFactory.cs
HealthMonitoringSection.cs
HealthMonitoringSectionHelper.cs
HostingEnvironmentSection.cs
HostingPreferredMapPath.cs
HttpCapabilitiesBase.cs
HttpCapabilitiesEvaluator.cs
HttpCapabilitiesSectionHandler.cs
HttpConfigurationContext.cs
HttpConfigurationSystem.cs
HttpCookiesSection.cs
HttpHandlerAction.cs
HttpHandlerActionCollection.cs
HttpHandlersSection.cs
HttpModuleAction.cs
HttpModuleActionCollection.cs
HttpModulesSection.cs
HttpRuntimeSection.cs
IApplicationContext.cs
IAssemblyCache.cs
IAssemblyCacheItem.cs
IAssemblyName.cs
IConfigMapPath.cs
IConfigMapPathFactory.cs
IGac.cs
IISMapPath.cs
IISVersionHelper.cs
IRemoteWebConfigurationHostServer.cs
IServerConfig.cs
IServerConfig2.cs
IdentitySection.cs
IgnoreDeviceFilterElement.cs
IgnoreDeviceFilterElementCollection.cs
ImpersonateTokenRef.cs
LowerCaseStringConverter.cs
MTConfigUtil.cs
MULTI_QI.cs
MachineKeyCompatibilityMode.cs
MachineKeySection.cs
MachineKeyValidation.cs
MachineKeyValidationConverter.cs
MapPathCacheInfo.cs
MembershipSection.cs
MetabaseServerConfig.cs
NamespaceCollection.cs
NamespaceInfo.cs
NativeConfig.cs
NullRuntimeConfig.cs
OutputCacheProfile.cs
OutputCacheProfileCollection.cs
OutputCacheSection.cs
OutputCacheSettingsSection.cs
PagesEnableSessionState.cs
PagesSection.cs
PartialTrustVisibleAssembliesSection.cs
PartialTrustVisibleAssembly.cs
PartialTrustVisibleAssemblyCollection.cs
PassportAuthentication.cs
ProcessHostConfigUtils.cs
ProcessHostMapPath.cs
ProcessHostServerConfig.cs
ProcessModelComAuthenticationLevel.cs
ProcessModelComImpersonationLevel.cs
ProcessModelLogLevel.cs
ProcessModelSection.cs
ProfileGroupSettings.cs
ProfileGroupSettingsCollection.cs
ProfileGuidedOptimizationsFlags.cs
ProfilePropertyNameValidator.cs
ProfilePropertySettings.cs
ProfilePropertySettingsCollection.cs
ProfileSection.cs
ProfileSettings.cs
ProfileSettingsCollection.cs
ProtocolsConfiguration.cs
ProtocolsConfigurationEntry.cs
ProtocolsConfigurationHandler.cs
ProtocolsSection.cs
ProvidersHelper.cs
RegexMatchTimeoutValidator.cs
RegexMatchTimeoutValidatorAttribute.cs
RegexWorker.cs
RemoteWebConfigurationHost.cs
RemoteWebConfigurationHostServer.cs
RemoteWebConfigurationHostStream.cs
RoleManagerSection.cs
RootProfilePropertySettingsCollection.cs
RpcAuthent.cs
RpcAuthor.cs
RpcImpers.cs
RpcLevel.cs
RuleInfoComparer.cs
RuleSettings.cs
RuleSettingsCollection.cs
RuntimeConfig.cs
RuntimeConfigLKG.cs
SecurityPolicySection.cs
SerializationMode.cs
SessionPageStateSection.cs
SessionStateSection.cs
SiteMapSection.cs
SqlCacheDependencyDatabase.cs
SqlCacheDependencyDatabaseCollection.cs
SqlCacheDependencySection.cs
StdValidatorsAndConverters.cs
StrongNameUtility.cs
SystemWebCachingSectionGroup.cs
SystemWebSectionGroup.cs
TagMapCollection.cs
TagMapInfo.cs
TagPrefixCollection.cs
TagPrefixInfo.cs
TicketCompatibilityMode.cs
TraceDisplayMode.cs
TraceSection.cs
TransformerInfo.cs
TransformerInfoCollection.cs
TrustLevel.cs
TrustLevelCollection.cs
TrustSection.cs
UrlAuthFailedErrorFormatter.cs
UrlMapping.cs
UrlMappingCollection.cs
UrlMappingsSection.cs
UserMapPath.cs
VersionConverter.cs
VersionValidator.cs
VirtualDirectoryMapping.cs
VirtualDirectoryMappingCollection.cs
WebApplicationLevel.cs
WebBaseEventKeyComparer.cs
WebConfigurationFileMap.cs
WebConfigurationHost.cs
WebConfigurationHostFileChange.cs
WebConfigurationManager.cs
WebContext.cs
WebControlsSection.cs
WebLevel.cs
WebPartsPersonalization.cs
WebPartsPersonalizationAuthorization.cs
WebPartsSection.cs
XhtmlConformanceMode.cs
XhtmlConformanceSection.cs
serverconfig.cs
DataAccess
DataAnnotations
Handlers
Hosting
Instrumentation
InternalApis
IntraPartitionAPIs
Management
ModelBinding
Profile
Properties
Routing
Security
State
UI
Util
WebSockets
misc
AspNetEventSource.cs
AspNetSynchronizationContext.cs
AspNetSynchronizationContextBase.cs
BufferAllocator.cs
CachedPathData.cs
CrossSiteScriptingValidation.cs
DefaultHttpHandler.cs
DynamicModuleRegistry.cs
DynamicValidationShim.cs
ErrorFormatter.cs
EtwTrace.cs
EventHandlerTaskAsyncHelper.cs
FileChangesMonitor.cs.REMOVED.git-id
GlobalSuppressions.cs.REMOVED.git-id
GlobalSuppressions2.cs.REMOVED.git-id
GlobalSuppressions3.cs
GlobalSuppressions4.cs
HTTPNotFoundHandler.cs
HtmlString.cs
HttpApplication.cs.REMOVED.git-id
HttpApplicationFactory.cs
HttpAsyncResult.cs
HttpBrowserCapabilities.cs
HttpBufferlessInputStream.cs
HttpCacheParams.cs
HttpCachePolicy.cs
HttpCacheVary.cs
HttpCacheVaryByContentEncodings.cs
HttpChannelBindingToken.cs
HttpClientCertificate.cs
HttpContext.cs
HttpCookie.cs
HttpCookieCollection.cs
HttpDebugHandler.cs
HttpDictionary.cs
HttpException.cs
HttpFileCollection.cs
HttpHeaderCollection.cs
HttpInputStream.cs
HttpModuleCollection.cs
HttpPostedFile.cs
HttpRawResponse.cs
HttpRequest.cs.REMOVED.git-id
HttpResponse.cs.REMOVED.git-id
HttpResponseHeader.cs
HttpRuntime.cs.REMOVED.git-id
HttpServerVarsCollection.cs
HttpTaskAsyncHandler.cs
HttpValueCollection.cs
HttpWriter.cs
IHtmlString.cs
IHttpAsyncHandler.cs
IHttpHandler.cs
IHttpHandlerFactory.cs
IHttpModule.cs
IPrincipalContainer.cs
IRequestCompletedNotifier.cs
ISubscriptionToken.cs
ITlsTokenBindingInfo.cs
IdleTimeoutMonitor.cs
IisTraceListener.cs
ImpersonationContext.cs
ImplicitAsyncPreloadModule.cs
IntSecurity.cs
LegacyAspNetSynchronizationContext.cs
MimeMapping.cs
ModuleConfigurationInfo.cs
ModulesEntry.cs
MultipartContentParser.cs
NativeMethods.cs
NotificationContext.cs
OutputCacheModule.cs
PartitionResolver.cs
PerfCounters.cs
PipelineModuleStepContainer.cs
PreApplicationStartMethodAttribute.cs
ProcessInfo.cs
ProcessModelInfo.cs
ReadEntityBodyMode.cs
RequestNotification.cs
RequestNotificationStatus.cs
RequestQueue.cs
RequestTimeoutManager.cs
RootedObjects.cs
SafeNativeMethods.cs
SiteMap.cs
SiteMapNode.cs
SiteMapNodeCollection.cs
SiteMapProvider.cs
StaticFileHandler.cs
StaticSiteMapProvider.cs
StringResourceManager.cs
System.Web.txt.REMOVED.git-id
TaskAsyncHelper.cs
TaskWrapperAsyncResult.cs
ThreadContext.cs
UnsafeNativeMethods.cs
UnvalidatedRequestValues.cs
UnvalidatedRequestValuesBase.cs
UnvalidatedRequestValuesWrapper.cs
UrlMappingsModule.cs
ValidateStringCallback.cs
VirtualPath.cs
VirtualPathUtility.cs
WebCategoryAttribute.cs
WebPageTraceListener.cs
WebSocketPipeline.cs
WebSocketTransitionState.cs
WebSysDefaultValueAttribute.cs
WebSysDescriptionAttribute.cs
WebSysDisplayNameAttribute.cs
WorkerRequest.cs
XmlSiteMapProvider.cs
cacheexpires.cspp
cacheusage.cspp
httpapplicationstate.cs
httpserverutility.cs
httpstaticobjectscollection.cs
System.Web.ApplicationServices
System.Web.DataVisualization
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.WorkflowServices
System.Xaml.Hosting
System.Xml
System.Xml.Linq
XamlBuildTask
mscorlib
LICENSE.txt
PATENTS.TXT
README.Mono.md
README.md
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
340 lines
14 KiB
C#
340 lines
14 KiB
C#
//------------------------------------------------------------------------------
|
|
// <copyright file="HttpConfigurationSystem.cs" company="Microsoft">
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// </copyright>
|
|
//------------------------------------------------------------------------------
|
|
|
|
namespace System.Web.Configuration {
|
|
using System.Configuration.Internal;
|
|
using Microsoft.Win32;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Web.Caching;
|
|
using System.Web.Hosting;
|
|
using System.Xml;
|
|
using System.Web.Util;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using System.Security;
|
|
using System.Security.Permissions;
|
|
|
|
using CultureInfo = System.Globalization.CultureInfo;
|
|
using Debug = System.Web.Util.Debug;
|
|
using UnicodeEncoding = System.Text.UnicodeEncoding;
|
|
using UrlPath = System.Web.Util.UrlPath;
|
|
|
|
internal class HttpConfigurationSystem : IInternalConfigSystem {
|
|
private const string InternalConfigSettingsFactoryTypeString = "System.Configuration.Internal.InternalConfigSettingsFactory, " + AssemblyRef.SystemConfiguration;
|
|
internal const string ConfigSystemTypeString = "System.Configuration.Internal.ConfigSystem, " + AssemblyRef.SystemConfiguration;
|
|
|
|
#if !PLATFORM_UNIX // File system paths must be lowercased in UNIX
|
|
internal const string MachineConfigSubdirectory = "Config";
|
|
#else // !PLATFORM_UNIX
|
|
internal const string MachineConfigSubdirectory = "config";
|
|
#endif // !PLATFORM_UNIX
|
|
internal const string MachineConfigFilename = "machine.config";
|
|
internal const string RootWebConfigFilename = "web.config";
|
|
internal const string WebConfigFileName = "web.config";
|
|
internal const string InetsrvDirectoryName = "inetsrv";
|
|
internal const string ApplicationHostConfigFileName = "applicationHost.config";
|
|
|
|
static private object s_initLock;
|
|
static private volatile bool s_inited;
|
|
|
|
// Supports IInternalConfigSystem and the file change dependency delegate
|
|
static private HttpConfigurationSystem s_httpConfigSystem;
|
|
static private IConfigSystem s_configSystem;
|
|
|
|
static private IConfigMapPath s_configMapPath;
|
|
static private WebConfigurationHost s_configHost;
|
|
static private FileChangeEventHandler s_fileChangeEventHandler;
|
|
static private string s_MsCorLibDirectory;
|
|
static private string s_MachineConfigurationDirectory;
|
|
static private string s_MachineConfigurationFilePath;
|
|
static private string s_RootWebConfigurationFilePath;
|
|
|
|
static private IInternalConfigRoot s_configRoot;
|
|
static private IInternalConfigSettingsFactory s_configSettingsFactory;
|
|
static private bool s_initComplete;
|
|
|
|
static HttpConfigurationSystem() {
|
|
s_initLock = new object();
|
|
}
|
|
|
|
HttpConfigurationSystem() {}
|
|
|
|
//
|
|
// Set this configuration system to the default for requests ConfigurationManager.GetSection
|
|
//
|
|
static internal void EnsureInit(IConfigMapPath configMapPath, bool listenToFileChanges, bool initComplete) {
|
|
if (!s_inited) {
|
|
lock (s_initLock) {
|
|
if (!s_inited) {
|
|
s_initComplete = initComplete;
|
|
|
|
// Use the IIS map path if one is not explicitly provided
|
|
if (configMapPath == null) {
|
|
configMapPath = IISMapPath.GetInstance();
|
|
}
|
|
|
|
s_configMapPath = configMapPath;
|
|
|
|
Type typeConfigSystem = Type.GetType(ConfigSystemTypeString, true);
|
|
s_configSystem = (IConfigSystem) Activator.CreateInstance(typeConfigSystem, true);
|
|
s_configSystem.Init(
|
|
typeof(WebConfigurationHost), // The config host we'll create and use
|
|
// The remaining parameters are passed to the config host:
|
|
true, // Use the supplied configMapPath
|
|
s_configMapPath, // the configMapPath to use
|
|
null, // ConfigurationFileMap
|
|
HostingEnvironment.ApplicationVirtualPath, // app path
|
|
HostingEnvironment.SiteNameNoDemand, // app site name
|
|
HostingEnvironment.SiteID); // app site ID
|
|
|
|
s_configRoot = s_configSystem.Root;
|
|
s_configHost = (WebConfigurationHost) s_configSystem.Host;
|
|
|
|
// Register for config changed notifications
|
|
HttpConfigurationSystem configSystem = new HttpConfigurationSystem();
|
|
|
|
if (listenToFileChanges) {
|
|
s_configRoot.ConfigChanged += new InternalConfigEventHandler(configSystem.OnConfigurationChanged);
|
|
}
|
|
|
|
// Set the configSystem into the ConfigurationManager class.
|
|
// Please note that factory.SetConfigurationSystem will end up calling
|
|
// ConfigurationManager.SetConfigurationSystem, which is an internal static method
|
|
// in System.Configuration.dll. If we want to call that here, we have to use
|
|
// reflection and that's what we want to avoid.
|
|
Type typeFactory = Type.GetType(InternalConfigSettingsFactoryTypeString, true);
|
|
s_configSettingsFactory = (IInternalConfigSettingsFactory) Activator.CreateInstance(typeFactory, true);
|
|
s_configSettingsFactory.SetConfigurationSystem(configSystem, initComplete);
|
|
|
|
// The system has been successfully set, so mark that we should use it.
|
|
s_httpConfigSystem = configSystem;
|
|
|
|
// Mark as having completed initialization after s_httpConfigSystem has been set.
|
|
// s_inited is coordinated with s_httpConfigSystem in UseHttpConfigurationSystem.
|
|
s_inited = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
Debug.Assert(s_httpConfigSystem != null, "s_httpConfigSystem != null - The appdomain is using the client configuration system.");
|
|
}
|
|
|
|
static internal void CompleteInit() {
|
|
Debug.Assert(!s_initComplete, "!s_initComplete");
|
|
s_configSettingsFactory.CompleteInit();
|
|
s_configSettingsFactory = null;
|
|
}
|
|
|
|
// Return true if the HttpConfigurationSystem is being used
|
|
// by ConfigurationManager.
|
|
static internal bool UseHttpConfigurationSystem {
|
|
get {
|
|
if (!s_inited) {
|
|
lock (s_initLock) {
|
|
if (!s_inited) {
|
|
//
|
|
// If we ask whether the HttpConfigurationSystem is in use, and it has not
|
|
// been initialized, then this caller is going to end up using the client
|
|
// configuration system. So prevent initialization of the HttpConfigurationSystem
|
|
// by setting s_inited = true.
|
|
//
|
|
s_inited = true;
|
|
Debug.Assert(s_httpConfigSystem == null, "s_httpConfigSystem == null");
|
|
}
|
|
}
|
|
}
|
|
|
|
return s_httpConfigSystem != null;
|
|
}
|
|
}
|
|
|
|
// Return true if the HttpConfigurationSystem is already loaded
|
|
// by ConfigurationManager.
|
|
static internal bool IsSet {
|
|
get {
|
|
return s_httpConfigSystem != null;
|
|
}
|
|
}
|
|
|
|
|
|
//
|
|
// Return the config object for the current context.
|
|
// If the HttpContext is not available, get the config object
|
|
// for the web application path.
|
|
//
|
|
object IInternalConfigSystem.GetSection(string configKey) {
|
|
return HttpConfigurationSystem.GetSection(configKey);
|
|
}
|
|
|
|
// Does not support refresh - the appdomain will restart if
|
|
// a file changes.
|
|
void IInternalConfigSystem.RefreshConfig(string sectionName) {}
|
|
|
|
// Supports user config
|
|
bool IInternalConfigSystem.SupportsUserConfig {
|
|
get {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// GetSection
|
|
//
|
|
// Get the Config for the current context
|
|
//
|
|
static internal object GetSection(string sectionName) {
|
|
HttpContext context = HttpContext.Current;
|
|
if (context != null) {
|
|
return context.GetSection(sectionName);
|
|
}
|
|
else {
|
|
// If there is no context, then lets get the config for
|
|
// the application we are hosted in.
|
|
return GetApplicationSection(sectionName);
|
|
}
|
|
}
|
|
|
|
// GetSection
|
|
//
|
|
// Get the Config for a specific path
|
|
//
|
|
static internal object GetSection(string sectionName, VirtualPath path) {
|
|
Debug.Assert(UseHttpConfigurationSystem, "UseHttpConfigurationSystem");
|
|
|
|
CachedPathData pathData;
|
|
|
|
pathData = CachedPathData.GetVirtualPathData(path, true);
|
|
|
|
return pathData.ConfigRecord.GetSection(sectionName);
|
|
}
|
|
|
|
static internal object GetSection(string sectionName, string path) {
|
|
return GetSection(sectionName, VirtualPath.CreateNonRelativeAllowNull(path));
|
|
}
|
|
|
|
// GetAppSection
|
|
//
|
|
// Get the Config for a specific path
|
|
//
|
|
static internal object GetApplicationSection(string sectionName) {
|
|
Debug.Assert(UseHttpConfigurationSystem, "UseHttpConfigurationSystem");
|
|
|
|
CachedPathData pathData;
|
|
|
|
pathData = CachedPathData.GetApplicationPathData();
|
|
|
|
return pathData.ConfigRecord.GetSection(sectionName);
|
|
}
|
|
|
|
|
|
//
|
|
// Return the unique configuration record for a config path.
|
|
// Used by CachedPathData to retreive config records.
|
|
//
|
|
static internal IInternalConfigRecord GetUniqueConfigRecord(string configPath) {
|
|
if (!UseHttpConfigurationSystem)
|
|
return null;
|
|
|
|
IInternalConfigRecord configRecord = s_configRoot.GetUniqueConfigRecord(configPath);
|
|
return configRecord;
|
|
}
|
|
|
|
static internal void AddFileDependency(String file) {
|
|
if (String.IsNullOrEmpty(file))
|
|
return;
|
|
#if !FEATURE_PAL // No file change notification in Coriolis
|
|
if (UseHttpConfigurationSystem) {
|
|
if (s_fileChangeEventHandler == null) {
|
|
s_fileChangeEventHandler = new FileChangeEventHandler(s_httpConfigSystem.OnConfigFileChanged);
|
|
}
|
|
|
|
HttpRuntime.FileChangesMonitor.StartMonitoringFile(file, s_fileChangeEventHandler);
|
|
}
|
|
#endif // !FEATURE_PAL
|
|
}
|
|
|
|
internal void OnConfigurationChanged(Object sender, InternalConfigEventArgs e) {
|
|
HttpRuntime.OnConfigChange(message: null);
|
|
}
|
|
|
|
internal void OnConfigFileChanged(Object sender, FileChangeEvent e) {
|
|
string message = FileChangesMonitor.GenerateErrorMessage(e.Action, e.FileName);
|
|
HttpRuntime.OnConfigChange(message);
|
|
}
|
|
|
|
static internal String MsCorLibDirectory {
|
|
[FileIOPermissionAttribute(SecurityAction.Assert, AllFiles=FileIOPermissionAccess.PathDiscovery)]
|
|
get {
|
|
if (s_MsCorLibDirectory == null) {
|
|
s_MsCorLibDirectory = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();
|
|
}
|
|
|
|
return s_MsCorLibDirectory;
|
|
}
|
|
}
|
|
|
|
static internal string MachineConfigurationDirectory {
|
|
get {
|
|
if (s_MachineConfigurationDirectory == null) {
|
|
#if !FEATURE_PAL
|
|
s_MachineConfigurationDirectory = Path.Combine(MsCorLibDirectory, MachineConfigSubdirectory);
|
|
#else // !FEATURE_PAL
|
|
System.UInt32 length = 0;
|
|
|
|
// Get the required size
|
|
if (!UnsafeNativeMethods.GetMachineConfigurationDirectory(null, ref length)) {
|
|
throw new System.ComponentModel.Win32Exception();
|
|
}
|
|
|
|
// Now, create the string and call again
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder((int)length);
|
|
|
|
if (!UnsafeNativeMethods.GetMachineConfigurationDirectory(sb, ref length)) {
|
|
throw new System.ComponentModel.Win32Exception();
|
|
}
|
|
|
|
s_MachineConfigurationDirectory = sb.ToString();
|
|
#endif // !FEATURE_PAL
|
|
}
|
|
|
|
return s_MachineConfigurationDirectory;
|
|
}
|
|
}
|
|
|
|
static internal string MachineConfigurationFilePath {
|
|
get {
|
|
if (s_MachineConfigurationFilePath == null) {
|
|
s_MachineConfigurationFilePath = Path.Combine(MachineConfigurationDirectory, MachineConfigFilename);
|
|
}
|
|
|
|
return s_MachineConfigurationFilePath;
|
|
}
|
|
}
|
|
|
|
static internal string RootWebConfigurationFilePath {
|
|
get {
|
|
if (s_RootWebConfigurationFilePath == null) {
|
|
s_RootWebConfigurationFilePath = Path.Combine(MachineConfigurationDirectory, RootWebConfigFilename);
|
|
}
|
|
|
|
return s_RootWebConfigurationFilePath;
|
|
}
|
|
// for IIS 7, support setting this file path to support the hostable
|
|
// web core and admin scenarios
|
|
set {
|
|
s_RootWebConfigurationFilePath = value;
|
|
if (null == s_RootWebConfigurationFilePath) {
|
|
s_RootWebConfigurationFilePath = Path.Combine(MachineConfigurationDirectory, RootWebConfigFilename);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|