Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Configuration / serverconfig.cs / 5 / serverconfig.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Configuration {
using System.Configuration;
using System.Collections;
using System.Globalization;
using System.Text;
using System.Threading;
using System.Web.Util;
using System.Web.Hosting;
using System.Web.Caching;
using System.Web.Compilation;
using Microsoft.Win32;
//
// Abstracts differences between config retreived from IIS 6 metabase
// and config retreived from new IIS7 configuration system.
//
static internal class ServerConfig {
static int s_iisMajorVersion = 0;
internal static bool UseMetabase {
get {
if (s_iisMajorVersion == 0) {
int version;
try {
object ver = Registry.GetValue("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\InetStp", "MajorVersion", 0);
version = (ver != null) ? (int) ver : -1;
}
catch (ArgumentException) {
// Ignore ArgumentException from Registry.GetValue. This may indicate that the key does not exist, i.e. IIS not installed
version = -1; // Key not found
}
Interlocked.CompareExchange(ref s_iisMajorVersion, version, 0);
}
return s_iisMajorVersion <= 6;
}
}
static internal IServerConfig GetInstance() {
// IIS 7 bits on <= IIS 6: use the metabase
if (UseMetabase) {
return MetabaseServerConfig.GetInstance();
}
return ProcessHostServerConfig.GetInstance();
}
//
// Return true in cases where web server configuration should be used
// to resolve paths.
//
static int s_useServerConfig = -1;
static internal bool UseServerConfig {
get {
if (s_useServerConfig == -1) {
int useServerConfig = 0;
// Must use web server config if there is no hosting environment
if (!HostingEnvironment.IsHosted) {
useServerConfig = 1;
}
// Hosting environment is the web server
else if (HostingEnvironment.ApplicationHost is ISAPIApplicationHost) {
useServerConfig = 1;
}
// Hosting environment is the web server
else if (HostingEnvironment.IsUnderIISProcess && !BuildManagerHost.InClientBuildManager) {
useServerConfig = 1;
}
Interlocked.CompareExchange(ref s_useServerConfig, useServerConfig, -1);
}
return s_useServerConfig == 1;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Web.Configuration {
using System.Configuration;
using System.Collections;
using System.Globalization;
using System.Text;
using System.Threading;
using System.Web.Util;
using System.Web.Hosting;
using System.Web.Caching;
using System.Web.Compilation;
using Microsoft.Win32;
//
// Abstracts differences between config retreived from IIS 6 metabase
// and config retreived from new IIS7 configuration system.
//
static internal class ServerConfig {
static int s_iisMajorVersion = 0;
internal static bool UseMetabase {
get {
if (s_iisMajorVersion == 0) {
int version;
try {
object ver = Registry.GetValue("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\InetStp", "MajorVersion", 0);
version = (ver != null) ? (int) ver : -1;
}
catch (ArgumentException) {
// Ignore ArgumentException from Registry.GetValue. This may indicate that the key does not exist, i.e. IIS not installed
version = -1; // Key not found
}
Interlocked.CompareExchange(ref s_iisMajorVersion, version, 0);
}
return s_iisMajorVersion <= 6;
}
}
static internal IServerConfig GetInstance() {
// IIS 7 bits on <= IIS 6: use the metabase
if (UseMetabase) {
return MetabaseServerConfig.GetInstance();
}
return ProcessHostServerConfig.GetInstance();
}
//
// Return true in cases where web server configuration should be used
// to resolve paths.
//
static int s_useServerConfig = -1;
static internal bool UseServerConfig {
get {
if (s_useServerConfig == -1) {
int useServerConfig = 0;
// Must use web server config if there is no hosting environment
if (!HostingEnvironment.IsHosted) {
useServerConfig = 1;
}
// Hosting environment is the web server
else if (HostingEnvironment.ApplicationHost is ISAPIApplicationHost) {
useServerConfig = 1;
}
// Hosting environment is the web server
else if (HostingEnvironment.IsUnderIISProcess && !BuildManagerHost.InClientBuildManager) {
useServerConfig = 1;
}
Interlocked.CompareExchange(ref s_useServerConfig, useServerConfig, -1);
}
return s_useServerConfig == 1;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TraceUtility.cs
- XmlSerializationGeneratedCode.cs
- CompiledWorkflowDefinitionContext.cs
- ObjectListFieldsPage.cs
- TextPointer.cs
- HtmlTableRowCollection.cs
- HttpDictionary.cs
- HostSecurityManager.cs
- ContentPosition.cs
- Pair.cs
- ExtenderControl.cs
- _LocalDataStore.cs
- DecimalConstantAttribute.cs
- DefaultEventAttribute.cs
- InternalResources.cs
- XmlValueConverter.cs
- SettingsBase.cs
- SQLDateTime.cs
- NotImplementedException.cs
- ServiceRouteHandler.cs
- TypeConverterBase.cs
- ConfigurationStrings.cs
- UnmanagedBitmapWrapper.cs
- SchemaElementLookUpTable.cs
- SqlProcedureAttribute.cs
- CompilerCollection.cs
- WebControlAdapter.cs
- DynamicMetaObjectBinder.cs
- WinEventQueueItem.cs
- EditorPartDesigner.cs
- FixedPage.cs
- GrammarBuilder.cs
- SectionXmlInfo.cs
- __Filters.cs
- InProcStateClientManager.cs
- RichTextBoxConstants.cs
- XamlVector3DCollectionSerializer.cs
- LambdaCompiler.Address.cs
- PointLight.cs
- BufferBuilder.cs
- AutoResetEvent.cs
- OperationContractAttribute.cs
- QilFactory.cs
- AuthenticationServiceManager.cs
- FileDataSourceCache.cs
- UniqueConstraint.cs
- DateRangeEvent.cs
- IsolatedStorage.cs
- MexTcpBindingCollectionElement.cs
- XmlDomTextWriter.cs
- PerspectiveCamera.cs
- SimpleWorkerRequest.cs
- _FtpDataStream.cs
- ObjectQueryState.cs
- SplashScreenNativeMethods.cs
- JsonUriDataContract.cs
- OutputScope.cs
- WindowsTreeView.cs
- QueryPageSettingsEventArgs.cs
- EntityDataSourceWizardForm.cs
- HttpRequestCacheValidator.cs
- AmbientLight.cs
- GCHandleCookieTable.cs
- _NegotiateClient.cs
- ToolStripButton.cs
- ObjectDataSourceSelectingEventArgs.cs
- XmlSchemaObjectTable.cs
- JsonStringDataContract.cs
- DataGridViewButtonColumn.cs
- RootBuilder.cs
- ToolStripPanelRenderEventArgs.cs
- SigningCredentials.cs
- ToolStripItemDataObject.cs
- MergePropertyDescriptor.cs
- DeferredReference.cs
- FigureHelper.cs
- FormattedText.cs
- XmlNamedNodeMap.cs
- Clock.cs
- ByteFacetDescriptionElement.cs
- CheckBoxPopupAdapter.cs
- StorageSetMapping.cs
- ExceptionNotification.cs
- CodeSubDirectory.cs
- DocumentOrderQuery.cs
- DictationGrammar.cs
- TextCharacters.cs
- RepeaterItemEventArgs.cs
- GiveFeedbackEventArgs.cs
- MachineKey.cs
- TextCompositionManager.cs
- UrlMappingsSection.cs
- DecoderFallbackWithFailureFlag.cs
- RegexTree.cs
- XmlnsDefinitionAttribute.cs
- XPathSingletonIterator.cs
- EntitySetBaseCollection.cs
- PersistenceProviderBehavior.cs
- DataGridViewCellStateChangedEventArgs.cs
- VerbConverter.cs