Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / Util / UrlPath.cs / 1 / UrlPath.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design.Util { using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Web.UI.Design; ////// Helper class for URLs. /// The only method in this class is borrowed directly from the runtime's /// System.Web.Util.UrlPath class. /// internal class UrlPath { // Only static methods, so hide constructor. private UrlPath() { } ////// Returns true if the path is an absolute physical path. /// private static bool IsAbsolutePhysicalPath(string path) { if (path == null || path.Length < 3) return false; if (path.StartsWith("\\\\", StringComparison.Ordinal)) return true; return (Char.IsLetter(path[0]) && path[1] == ':' && path[2] == '\\'); } ////// Maps an arbitrary path (physical absolute, app-relative, relative) to /// a physical path using designer host services. If the path cannot be /// mapped because certain services are not present, null is returned. /// internal static string MapPath(IServiceProvider serviceProvider, string path) { if (path.Length == 0) { return null; } if (IsAbsolutePhysicalPath(path)) { // Absolute path return path; } else { // Root relative path - use designer host service to map the path WebFormsRootDesigner rootDesigner = null; if (serviceProvider != null) { IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost)); if ((designerHost != null) && (designerHost.RootComponent != null)) { rootDesigner = designerHost.GetDesigner(designerHost.RootComponent) as WebFormsRootDesigner; if (rootDesigner != null) { string resolvedUrl = rootDesigner.ResolveUrl(path); // Use the WebApplication server to get a physical path from the app-relative path IWebApplication webApplicationService = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication)); if (webApplicationService != null) { IProjectItem dataFileProjectItem = webApplicationService.GetProjectItemFromUrl(resolvedUrl); if (dataFileProjectItem != null) { return dataFileProjectItem.PhysicalPath; } } } } } } // Could not get service to map path, return null return null; } } } // 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
- SetterBaseCollection.cs
- DataControlCommands.cs
- SafeThreadHandle.cs
- Win32Native.cs
- RepeatButtonAutomationPeer.cs
- WindowsRichEditRange.cs
- DataServicePagingProviderWrapper.cs
- FormatterConverter.cs
- TimelineClockCollection.cs
- AtomPub10CategoriesDocumentFormatter.cs
- EncodingFallbackAwareXmlTextWriter.cs
- DrawingCollection.cs
- SerializationInfo.cs
- DataFormats.cs
- XpsPackagingPolicy.cs
- ExternalException.cs
- UrlRoutingHandler.cs
- ICspAsymmetricAlgorithm.cs
- SystemIcmpV4Statistics.cs
- HostingEnvironmentSection.cs
- HotCommands.cs
- PieceDirectory.cs
- _SSPISessionCache.cs
- DataGridViewCellEventArgs.cs
- ErrorsHelper.cs
- ContentTypeSettingClientMessageFormatter.cs
- DesignerActionTextItem.cs
- ScriptResourceInfo.cs
- HijriCalendar.cs
- GC.cs
- AutomationPropertyInfo.cs
- Missing.cs
- DataTableMappingCollection.cs
- OptimizedTemplateContent.cs
- DurableInstancingOptions.cs
- ImportRequest.cs
- X509Logo.cs
- DbParameterCollectionHelper.cs
- storepermission.cs
- HttpDebugHandler.cs
- RC2.cs
- DataRowComparer.cs
- ToolstripProfessionalRenderer.cs
- Process.cs
- WebEventCodes.cs
- CodePageEncoding.cs
- Form.cs
- ValueProviderWrapper.cs
- EntityDataSourceEntityTypeFilterItem.cs
- QueryableFilterUserControl.cs
- WindowsPrincipal.cs
- GeneralTransform3DCollection.cs
- ObjectListCommandEventArgs.cs
- NodeFunctions.cs
- RectangleHotSpot.cs
- TextElementEditingBehaviorAttribute.cs
- ServiceSettingsResponseInfo.cs
- DataGridViewCellMouseEventArgs.cs
- TitleStyle.cs
- AnnotationResourceChangedEventArgs.cs
- EventInfo.cs
- OracleDataReader.cs
- WindowsRegion.cs
- DuplicateWaitObjectException.cs
- StylusEventArgs.cs
- CalendarDataBindingHandler.cs
- IntSecurity.cs
- StrongTypingException.cs
- IOException.cs
- TextSegment.cs
- WebSysDescriptionAttribute.cs
- WebPartUserCapability.cs
- CompositeFontFamily.cs
- DependencyPropertyDescriptor.cs
- GcSettings.cs
- OutputWindow.cs
- SocketException.cs
- WebPartConnectionsConfigureVerb.cs
- CompiledXpathExpr.cs
- FrugalMap.cs
- EdmRelationshipRoleAttribute.cs
- LeaseManager.cs
- InstanceStore.cs
- _SingleItemRequestCache.cs
- DocumentGrid.cs
- CodeSubDirectory.cs
- ZipFileInfoCollection.cs
- _OverlappedAsyncResult.cs
- WebPartExportVerb.cs
- PolyBezierSegmentFigureLogic.cs
- XmlTypeMapping.cs
- InstancePersistenceException.cs
- SystemIPAddressInformation.cs
- RelationshipConstraintValidator.cs
- QueryComponents.cs
- XsltArgumentList.cs
- ManipulationVelocities.cs
- RSAPKCS1SignatureFormatter.cs
- Debug.cs
- CodeSnippetExpression.cs