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
- PointAnimationBase.cs
- XpsFilter.cs
- SqlBinder.cs
- ColumnBinding.cs
- ProviderSettingsCollection.cs
- ConfigXmlAttribute.cs
- XmlSchemaObject.cs
- _StreamFramer.cs
- UpdatePanelTrigger.cs
- XmlQueryContext.cs
- XmlSortKey.cs
- FormViewUpdatedEventArgs.cs
- TabControlToolboxItem.cs
- UndoEngine.cs
- TargetException.cs
- SectionVisual.cs
- InternalResources.cs
- EngineSiteSapi.cs
- DurationConverter.cs
- TextFormatterHost.cs
- ToolStripCustomTypeDescriptor.cs
- DeadCharTextComposition.cs
- CollectionViewGroupRoot.cs
- HtmlInputHidden.cs
- ByteStorage.cs
- ListViewItemSelectionChangedEvent.cs
- cookiecontainer.cs
- LoginUtil.cs
- EntityEntry.cs
- CodeTypeMember.cs
- StringExpressionSet.cs
- HtmlEncodedRawTextWriter.cs
- ToolStripDropTargetManager.cs
- smtppermission.cs
- XdrBuilder.cs
- IProducerConsumerCollection.cs
- CalendarTable.cs
- HMACSHA256.cs
- OracleException.cs
- Line.cs
- ApplicationProxyInternal.cs
- InputElement.cs
- SwitchAttribute.cs
- DataServiceCollectionOfT.cs
- GeneralTransform3D.cs
- DataGridViewToolTip.cs
- MetadataCache.cs
- ServerType.cs
- COM2ExtendedUITypeEditor.cs
- UriSection.cs
- DBAsyncResult.cs
- WindowsSlider.cs
- MemberMaps.cs
- XmlDataFileEditor.cs
- TdsParameterSetter.cs
- Encoder.cs
- BoundPropertyEntry.cs
- FileUpload.cs
- MostlySingletonList.cs
- HtmlInputPassword.cs
- DirectoryInfo.cs
- ControlIdConverter.cs
- DataGrid.cs
- Pkcs7Recipient.cs
- MemberRelationshipService.cs
- SequentialUshortCollection.cs
- BaseAddressElement.cs
- EncryptedPackageFilter.cs
- BitmapSourceSafeMILHandle.cs
- CodeGen.cs
- ExpressionVisitorHelpers.cs
- TypeConverterHelper.cs
- SecurityKeyIdentifierClause.cs
- TextServicesHost.cs
- RemoveStoryboard.cs
- VariableAction.cs
- InitializerFacet.cs
- DataPagerFieldItem.cs
- PreProcessInputEventArgs.cs
- StringSorter.cs
- CodeFieldReferenceExpression.cs
- UIServiceHelper.cs
- RouteCollection.cs
- CompiledXpathExpr.cs
- ChangePassword.cs
- SchemaCollectionCompiler.cs
- MetadataArtifactLoaderCompositeFile.cs
- LinqDataSourceStatusEventArgs.cs
- BaseHashHelper.cs
- SlipBehavior.cs
- TaiwanCalendar.cs
- OleAutBinder.cs
- RuntimeCompatibilityAttribute.cs
- Enum.cs
- HtmlShim.cs
- TransactedReceiveScope.cs
- ToolStripProgressBar.cs
- ProfileGroupSettingsCollection.cs
- Assign.cs
- ProjectedWrapper.cs