Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / serverconfig.cs / 1305376 / serverconfig.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Configuration; using System.Collections; using System.Globalization; using System.Security; using System.Security.Permissions; 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 { [RegistryPermissionAttribute(SecurityAction.Assert, Read = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\InetStp")] 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.ApplicationHostInternal 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.Security; using System.Security.Permissions; 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 { [RegistryPermissionAttribute(SecurityAction.Assert, Read = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\InetStp")] 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.ApplicationHostInternal 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
- HttpCachePolicyBase.cs
- HyperLinkDataBindingHandler.cs
- RIPEMD160Managed.cs
- ContainerFilterService.cs
- Root.cs
- BasicExpandProvider.cs
- ProfileProvider.cs
- TypedReference.cs
- ArrayConverter.cs
- StyleModeStack.cs
- util.cs
- Baml2006KeyRecord.cs
- CollectionChangeEventArgs.cs
- ColumnReorderedEventArgs.cs
- Rect3D.cs
- TraceLevelHelper.cs
- PartialTrustHelpers.cs
- OrderedDictionaryStateHelper.cs
- DetailsViewModeEventArgs.cs
- XmlBinaryReader.cs
- PersonalizationStateQuery.cs
- ServiceElementCollection.cs
- NamespaceEmitter.cs
- StreamUpdate.cs
- ScopeElementCollection.cs
- DockAndAnchorLayout.cs
- WmpBitmapDecoder.cs
- SvcMapFileSerializer.cs
- DesignerVerbCollection.cs
- FixedSOMContainer.cs
- LambdaSerializationException.cs
- TextRunTypographyProperties.cs
- altserialization.cs
- WindowsListViewItemStartMenu.cs
- StylusDownEventArgs.cs
- IndexOutOfRangeException.cs
- ServicePointManager.cs
- ControlBindingsCollection.cs
- Base64Stream.cs
- XmlDataSourceView.cs
- DocumentOrderComparer.cs
- Sequence.cs
- Buffer.cs
- Button.cs
- GrammarBuilderPhrase.cs
- TextEditorSelection.cs
- uribuilder.cs
- TextLine.cs
- HttpAsyncResult.cs
- WebPartEditorOkVerb.cs
- Interlocked.cs
- ConfigurationElementCollection.cs
- ValueConversionAttribute.cs
- PathGeometry.cs
- ISFClipboardData.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- ApplicationInterop.cs
- HeaderPanel.cs
- CardSpaceException.cs
- RoutedEventValueSerializer.cs
- HierarchicalDataBoundControl.cs
- BitmapMetadataBlob.cs
- FontStyleConverter.cs
- WorkflowFormatterBehavior.cs
- WebEventCodes.cs
- PeerNode.cs
- TextPointer.cs
- PostBackTrigger.cs
- DataGridTextColumn.cs
- DataGridViewEditingControlShowingEventArgs.cs
- Solver.cs
- DataGridViewCellParsingEventArgs.cs
- AdapterUtil.cs
- WizardStepBase.cs
- DataControlCommands.cs
- SqlServices.cs
- ClickablePoint.cs
- Model3D.cs
- HealthMonitoringSectionHelper.cs
- ListComponentEditor.cs
- CodePageUtils.cs
- GridViewSortEventArgs.cs
- CompilerInfo.cs
- StylusPlugin.cs
- MemberMaps.cs
- RightsDocument.cs
- EventListener.cs
- DefaultCommandConverter.cs
- CommonObjectSecurity.cs
- CompModHelpers.cs
- PrimitiveSchema.cs
- InkCanvasFeedbackAdorner.cs
- SetterBase.cs
- XmlIlVisitor.cs
- RegistryKey.cs
- WpfSharedXamlSchemaContext.cs
- CardSpaceShim.cs
- DragDrop.cs
- DisposableCollectionWrapper.cs
- TableLayoutStyle.cs