Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / xsp / System / Web / Configuration / HostingPreferredMapPath.cs / 4 / HostingPreferredMapPath.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System.Configuration; using System.Collections; using System.Globalization; using System.Xml; using System.Text; using System.Web.Util; using System.Web.UI; using System.IO; using System.Web.Hosting; // // IConfigMapPath that uses the HostingEnvironment's IConfigMapPath for // paths that it maps, and uses the web server IConfigMapPath for // all other paths. // // This allows us to use mappings for an app using SimpleApplicationHost, // while still correctly mapping paths outside the app. // class HostingPreferredMapPath : IConfigMapPath { IConfigMapPath _iisConfigMapPath; IConfigMapPath _hostingConfigMapPath; internal static IConfigMapPath GetInstance() { IConfigMapPath iisConfigMapPath = IISMapPath.GetInstance(); IConfigMapPath hostingConfigMapPath = HostingEnvironment.ConfigMapPath; // Only delegate if the types implementing IConfigMapPath are different. if (hostingConfigMapPath == null || iisConfigMapPath.GetType() == hostingConfigMapPath.GetType()) return iisConfigMapPath; return new HostingPreferredMapPath(iisConfigMapPath, hostingConfigMapPath); } HostingPreferredMapPath(IConfigMapPath iisConfigMapPath, IConfigMapPath hostingConfigMapPath) { _iisConfigMapPath = iisConfigMapPath; _hostingConfigMapPath = hostingConfigMapPath; } public string GetMachineConfigFilename() { string filename = _hostingConfigMapPath.GetMachineConfigFilename(); if (string.IsNullOrEmpty(filename)) { filename = _iisConfigMapPath.GetMachineConfigFilename(); } return filename; } public string GetRootWebConfigFilename() { string filename = _hostingConfigMapPath.GetRootWebConfigFilename(); if (string.IsNullOrEmpty(filename)) { filename = _iisConfigMapPath.GetRootWebConfigFilename(); } return filename; } public void GetPathConfigFilename( string siteID, string path, out string directory, out string baseName) { _hostingConfigMapPath.GetPathConfigFilename(siteID, path, out directory, out baseName); if (string.IsNullOrEmpty(directory)) { _iisConfigMapPath.GetPathConfigFilename(siteID, path, out directory, out baseName); } } public void GetDefaultSiteNameAndID(out string siteName, out string siteID) { _hostingConfigMapPath.GetDefaultSiteNameAndID(out siteName, out siteID); if (string.IsNullOrEmpty(siteID)) { _iisConfigMapPath.GetDefaultSiteNameAndID(out siteName, out siteID); } } public void ResolveSiteArgument(string siteArgument, out string siteName, out string siteID) { _hostingConfigMapPath.ResolveSiteArgument(siteArgument, out siteName, out siteID); if (string.IsNullOrEmpty(siteID)) { _iisConfigMapPath.ResolveSiteArgument(siteArgument, out siteName, out siteID); } } public string MapPath(string siteID, string path) { string physicalPath = _hostingConfigMapPath.MapPath(siteID, path); if (string.IsNullOrEmpty(physicalPath)) { physicalPath = _iisConfigMapPath.MapPath(siteID, path); } return physicalPath; } public string GetAppPathForPath(string siteID, string path) { string appPath = _hostingConfigMapPath.GetAppPathForPath(siteID, path); if (appPath == null) { appPath = _iisConfigMapPath.GetAppPathForPath(siteID, path); } return appPath; } } } // 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.Xml; using System.Text; using System.Web.Util; using System.Web.UI; using System.IO; using System.Web.Hosting; // // IConfigMapPath that uses the HostingEnvironment's IConfigMapPath for // paths that it maps, and uses the web server IConfigMapPath for // all other paths. // // This allows us to use mappings for an app using SimpleApplicationHost, // while still correctly mapping paths outside the app. // class HostingPreferredMapPath : IConfigMapPath { IConfigMapPath _iisConfigMapPath; IConfigMapPath _hostingConfigMapPath; internal static IConfigMapPath GetInstance() { IConfigMapPath iisConfigMapPath = IISMapPath.GetInstance(); IConfigMapPath hostingConfigMapPath = HostingEnvironment.ConfigMapPath; // Only delegate if the types implementing IConfigMapPath are different. if (hostingConfigMapPath == null || iisConfigMapPath.GetType() == hostingConfigMapPath.GetType()) return iisConfigMapPath; return new HostingPreferredMapPath(iisConfigMapPath, hostingConfigMapPath); } HostingPreferredMapPath(IConfigMapPath iisConfigMapPath, IConfigMapPath hostingConfigMapPath) { _iisConfigMapPath = iisConfigMapPath; _hostingConfigMapPath = hostingConfigMapPath; } public string GetMachineConfigFilename() { string filename = _hostingConfigMapPath.GetMachineConfigFilename(); if (string.IsNullOrEmpty(filename)) { filename = _iisConfigMapPath.GetMachineConfigFilename(); } return filename; } public string GetRootWebConfigFilename() { string filename = _hostingConfigMapPath.GetRootWebConfigFilename(); if (string.IsNullOrEmpty(filename)) { filename = _iisConfigMapPath.GetRootWebConfigFilename(); } return filename; } public void GetPathConfigFilename( string siteID, string path, out string directory, out string baseName) { _hostingConfigMapPath.GetPathConfigFilename(siteID, path, out directory, out baseName); if (string.IsNullOrEmpty(directory)) { _iisConfigMapPath.GetPathConfigFilename(siteID, path, out directory, out baseName); } } public void GetDefaultSiteNameAndID(out string siteName, out string siteID) { _hostingConfigMapPath.GetDefaultSiteNameAndID(out siteName, out siteID); if (string.IsNullOrEmpty(siteID)) { _iisConfigMapPath.GetDefaultSiteNameAndID(out siteName, out siteID); } } public void ResolveSiteArgument(string siteArgument, out string siteName, out string siteID) { _hostingConfigMapPath.ResolveSiteArgument(siteArgument, out siteName, out siteID); if (string.IsNullOrEmpty(siteID)) { _iisConfigMapPath.ResolveSiteArgument(siteArgument, out siteName, out siteID); } } public string MapPath(string siteID, string path) { string physicalPath = _hostingConfigMapPath.MapPath(siteID, path); if (string.IsNullOrEmpty(physicalPath)) { physicalPath = _iisConfigMapPath.MapPath(siteID, path); } return physicalPath; } public string GetAppPathForPath(string siteID, string path) { string appPath = _hostingConfigMapPath.GetAppPathForPath(siteID, path); if (appPath == null) { appPath = _iisConfigMapPath.GetAppPathForPath(siteID, path); } return appPath; } } } // 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
- ConstraintStruct.cs
- PolicyVersionConverter.cs
- OutOfProcStateClientManager.cs
- DesignerSerializationVisibilityAttribute.cs
- ImageField.cs
- SortDescription.cs
- HtmlControlPersistable.cs
- SafeNativeMethods.cs
- MaskDescriptors.cs
- Point3DAnimationBase.cs
- DataFormat.cs
- StringAnimationBase.cs
- ThreadStateException.cs
- DocumentEventArgs.cs
- PageVisual.cs
- CustomAttribute.cs
- PerspectiveCamera.cs
- WebCategoryAttribute.cs
- EventLog.cs
- VisualStyleElement.cs
- EditorServiceContext.cs
- CallbackValidatorAttribute.cs
- Logging.cs
- InertiaTranslationBehavior.cs
- ConfigXmlCDataSection.cs
- SqlDelegatedTransaction.cs
- _ListenerAsyncResult.cs
- OdbcParameterCollection.cs
- PreservationFileReader.cs
- BitmapPalette.cs
- TextContainerChangedEventArgs.cs
- PropertyChangedEventArgs.cs
- QueryOperationResponseOfT.cs
- EdmEntityTypeAttribute.cs
- Viewport3DVisual.cs
- MergeFailedEvent.cs
- Stack.cs
- Nodes.cs
- login.cs
- MenuItemCollection.cs
- ImageAttributes.cs
- _LocalDataStore.cs
- ChannelListenerBase.cs
- _ProxyRegBlob.cs
- WinInet.cs
- Typeface.cs
- Mutex.cs
- TemplateBindingExtension.cs
- CodeNamespaceCollection.cs
- TransactionFlowProperty.cs
- HttpCapabilitiesSectionHandler.cs
- SecurityCriticalDataForSet.cs
- SpecularMaterial.cs
- MemberCollection.cs
- TimelineGroup.cs
- IndicFontClient.cs
- Timer.cs
- TextSimpleMarkerProperties.cs
- EntityObject.cs
- SurrogateDataContract.cs
- ClusterRegistryConfigurationProvider.cs
- EnvironmentPermission.cs
- TextLineBreak.cs
- ModuleBuilderData.cs
- SystemResourceHost.cs
- TriggerActionCollection.cs
- RepeaterItemEventArgs.cs
- FontFamily.cs
- XslCompiledTransform.cs
- OracleCommandSet.cs
- BrowserDefinitionCollection.cs
- WinEventWrap.cs
- ManagementObject.cs
- ClientConvert.cs
- SplayTreeNode.cs
- WsdlEndpointConversionContext.cs
- Win32.cs
- TileModeValidation.cs
- HttpModuleAction.cs
- SectionXmlInfo.cs
- Quack.cs
- MapPathBasedVirtualPathProvider.cs
- UniqueIdentifierService.cs
- InstanceDataCollectionCollection.cs
- PageParserFilter.cs
- MulticastNotSupportedException.cs
- TextTreeObjectNode.cs
- BaseComponentEditor.cs
- SafeNativeMethods.cs
- NCryptSafeHandles.cs
- Task.cs
- PhysicalAddress.cs
- DataGridItem.cs
- ApplicationBuildProvider.cs
- OptionUsage.cs
- BamlWriter.cs
- PerformanceCounterNameAttribute.cs
- BitHelper.cs
- _AutoWebProxyScriptHelper.cs
- BinaryParser.cs