Code:
/ FXUpdate3074 / FXUpdate3074 / 1.1 / DEVDIV / depot / DevDiv / releases / whidbey / QFE / ndp / fx / src / xsp / System / Web / Configuration / serverconfig.cs / 3 / 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. //------------------------------------------------------------------------------ //// 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ResourceExpression.cs
- WorkflowPrinting.cs
- bidPrivateBase.cs
- SystemIPv4InterfaceProperties.cs
- TableCellCollection.cs
- SizeLimitedCache.cs
- RowParagraph.cs
- CurrentTimeZone.cs
- SliderAutomationPeer.cs
- Int32CAMarshaler.cs
- PartialCachingControl.cs
- StyleCollection.cs
- safemediahandle.cs
- DataStorage.cs
- ListViewSelectEventArgs.cs
- COM2IDispatchConverter.cs
- MediaContextNotificationWindow.cs
- HtmlLabelAdapter.cs
- SqlBinder.cs
- SqlHelper.cs
- HashSet.cs
- SpecialTypeDataContract.cs
- EdmItemCollection.cs
- BoolLiteral.cs
- ResourceExpression.cs
- XmlBinaryReader.cs
- ChangeNode.cs
- BamlResourceContent.cs
- ItemMap.cs
- Rect3D.cs
- Fonts.cs
- Journaling.cs
- AssemblyCollection.cs
- ContainerUIElement3D.cs
- HwndTarget.cs
- hebrewshape.cs
- ParseChildrenAsPropertiesAttribute.cs
- BoolLiteral.cs
- StreamingContext.cs
- COM2EnumConverter.cs
- _MultipleConnectAsync.cs
- DocumentViewerBaseAutomationPeer.cs
- AdPostCacheSubstitution.cs
- UndoManager.cs
- TableLayoutSettingsTypeConverter.cs
- WebPartsPersonalization.cs
- ZoneButton.cs
- documentsequencetextcontainer.cs
- IdentityReference.cs
- StatusBarPanel.cs
- CompositeControlDesigner.cs
- HTMLTextWriter.cs
- DeflateStreamAsyncResult.cs
- PermissionToken.cs
- CollectionChangeEventArgs.cs
- ApplicationCommands.cs
- DBConnectionString.cs
- GuidConverter.cs
- AdvancedBindingPropertyDescriptor.cs
- BaseCollection.cs
- XomlDesignerLoader.cs
- shaperfactoryquerycachekey.cs
- TextServicesHost.cs
- InfoCardX509Validator.cs
- DispatcherExceptionEventArgs.cs
- DataControlCommands.cs
- ManagementExtension.cs
- WebZone.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- DetailsViewPageEventArgs.cs
- PreservationFileWriter.cs
- AssemblyCacheEntry.cs
- ComplusEndpointConfigContainer.cs
- SetIterators.cs
- RunWorkerCompletedEventArgs.cs
- SingleConverter.cs
- IgnoreDataMemberAttribute.cs
- QilStrConcat.cs
- TraceListener.cs
- CustomAttributeSerializer.cs
- DoubleAnimationBase.cs
- XmlSchemaAll.cs
- EntityTypeEmitter.cs
- SingleConverter.cs
- XpsResourcePolicy.cs
- CodeDelegateCreateExpression.cs
- ToolStripCollectionEditor.cs
- MessageBox.cs
- pingexception.cs
- ScrollViewerAutomationPeer.cs
- DrawListViewColumnHeaderEventArgs.cs
- StrokeCollectionDefaultValueFactory.cs
- DynamicILGenerator.cs
- CellTreeNodeVisitors.cs
- ReadOnlyObservableCollection.cs
- IFormattable.cs
- DataBindingExpressionBuilder.cs
- OutputCacheProfileCollection.cs
- XmlDigitalSignatureProcessor.cs
- TabletDeviceInfo.cs