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
- PropertyPathWorker.cs
- NativeMethodsOther.cs
- _SafeNetHandles.cs
- CriticalHandle.cs
- Double.cs
- IdentifierCreationService.cs
- BatchParser.cs
- RenderDataDrawingContext.cs
- GeneratedCodeAttribute.cs
- PropertyAccessVisitor.cs
- CoreSwitches.cs
- XmlSchemaSimpleType.cs
- OpenFileDialog.cs
- TaskResultSetter.cs
- HitTestParameters3D.cs
- SamlAdvice.cs
- DigestTraceRecordHelper.cs
- ParallelDesigner.cs
- ListBoxItemWrapperAutomationPeer.cs
- HtmlTextArea.cs
- XmlnsPrefixAttribute.cs
- ContentIterators.cs
- OracleCommandBuilder.cs
- IconBitmapDecoder.cs
- FunctionMappingTranslator.cs
- ImageInfo.cs
- SettingsPropertyWrongTypeException.cs
- PrimitiveXmlSerializers.cs
- SqlHelper.cs
- SkewTransform.cs
- FactoryGenerator.cs
- DocumentOrderQuery.cs
- LongCountAggregationOperator.cs
- ComboBoxAutomationPeer.cs
- XmlSchemaValidator.cs
- Trigger.cs
- SqlDataSourceEnumerator.cs
- ShaperBuffers.cs
- WindowsIdentity.cs
- EncodingTable.cs
- ServiceDescriptionImporter.cs
- CustomAttributeSerializer.cs
- HandledEventArgs.cs
- TreeViewEvent.cs
- DrawingCollection.cs
- ParagraphResult.cs
- TextBoxAutomationPeer.cs
- SizeF.cs
- BlurBitmapEffect.cs
- KeyConstraint.cs
- DataTableExtensions.cs
- CommandManager.cs
- CompositeTypefaceMetrics.cs
- DataGridCellEditEndingEventArgs.cs
- DelimitedListTraceListener.cs
- Collection.cs
- BaseContextMenu.cs
- NavigationPropertyEmitter.cs
- QuaternionRotation3D.cs
- BooleanAnimationBase.cs
- SmiMetaData.cs
- KoreanLunisolarCalendar.cs
- DesignerTextWriter.cs
- AssemblyAssociatedContentFileAttribute.cs
- EventLogInformation.cs
- AutomationPeer.cs
- SelectorItemAutomationPeer.cs
- HtmlInputRadioButton.cs
- TagNameToTypeMapper.cs
- unsafenativemethodstextservices.cs
- ContextBase.cs
- PointF.cs
- WebUtil.cs
- ResourcesBuildProvider.cs
- HitTestFilterBehavior.cs
- TypeName.cs
- OperationValidationEventArgs.cs
- MetadataArtifactLoaderCompositeResource.cs
- PeerObject.cs
- MediaTimeline.cs
- DefaultProfileManager.cs
- SoapHelper.cs
- FormViewDeleteEventArgs.cs
- processwaithandle.cs
- UnhandledExceptionEventArgs.cs
- SHA256Managed.cs
- QualifiedCellIdBoolean.cs
- ReflectEventDescriptor.cs
- NameValueFileSectionHandler.cs
- Command.cs
- ZipPackage.cs
- EventDescriptorCollection.cs
- RTLAwareMessageBox.cs
- ObjectListFieldsPage.cs
- ValidationErrorEventArgs.cs
- BindingWorker.cs
- QilGenerator.cs
- AdapterDictionary.cs
- LinearGradientBrush.cs
- BaseTemplateBuildProvider.cs