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
- ExtensionDataReader.cs
- PagedDataSource.cs
- Ipv6Element.cs
- ObjectDataProvider.cs
- MemberHolder.cs
- WeakRefEnumerator.cs
- DataDocumentXPathNavigator.cs
- TogglePatternIdentifiers.cs
- ArgumentNullException.cs
- Size3D.cs
- WebPartHelpVerb.cs
- basevalidator.cs
- COM2ICategorizePropertiesHandler.cs
- DocumentViewerAutomationPeer.cs
- HtmlInputRadioButton.cs
- SqlEnums.cs
- WorkflowTransactionOptions.cs
- DragDrop.cs
- BaseDataBoundControl.cs
- Pts.cs
- MonthCalendar.cs
- Assembly.cs
- XslTransformFileEditor.cs
- ProcessHostConfigUtils.cs
- SqlDataSourceEnumerator.cs
- TcpProcessProtocolHandler.cs
- BaseConfigurationRecord.cs
- NameValueCollection.cs
- EditorZoneBase.cs
- _HeaderInfo.cs
- XmlJsonReader.cs
- EntitySqlQueryState.cs
- NotifyCollectionChangedEventArgs.cs
- CalendarTable.cs
- DataReceivedEventArgs.cs
- GroupedContextMenuStrip.cs
- SchemaNamespaceManager.cs
- ExpandCollapsePattern.cs
- TextEndOfLine.cs
- XmlTextWriter.cs
- DurableOperationAttribute.cs
- AVElementHelper.cs
- ProvideValueServiceProvider.cs
- VersionedStream.cs
- DataBindingCollection.cs
- SQLBytes.cs
- SourceFileBuildProvider.cs
- EnlistmentState.cs
- WebServiceHandler.cs
- TriggerBase.cs
- SettingsSection.cs
- ColorConverter.cs
- VBIdentifierNameEditor.cs
- FlowSwitchDesigner.xaml.cs
- LayoutEvent.cs
- MatchingStyle.cs
- ItemContainerGenerator.cs
- ControlSerializer.cs
- OrderedHashRepartitionStream.cs
- XmlDigitalSignatureProcessor.cs
- User.cs
- DragDeltaEventArgs.cs
- UserNameSecurityToken.cs
- Control.cs
- XPathCompileException.cs
- __ConsoleStream.cs
- SponsorHelper.cs
- SessionStateUtil.cs
- SignatureDescription.cs
- ListViewCommandEventArgs.cs
- RequestCache.cs
- ProtocolViolationException.cs
- EventRouteFactory.cs
- TextOutput.cs
- OciHandle.cs
- HostingEnvironment.cs
- DataGridHeaderBorder.cs
- ConfigurationPermission.cs
- StorageAssociationSetMapping.cs
- EncryptedReference.cs
- GridErrorDlg.cs
- CmsInterop.cs
- RawMouseInputReport.cs
- EmptyImpersonationContext.cs
- CompiledQueryCacheEntry.cs
- Imaging.cs
- VariantWrapper.cs
- ReaderContextStackData.cs
- Serializer.cs
- RequestCache.cs
- SRGSCompiler.cs
- KnownTypesHelper.cs
- Storyboard.cs
- Subtree.cs
- StateItem.cs
- OverlappedContext.cs
- ClipboardProcessor.cs
- PropertyIDSet.cs
- QuerySetOp.cs
- PlainXmlSerializer.cs