Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Internal / ResourceIDHelper.cs / 1305600 / ResourceIDHelper.cs
using System; using System.Text; using System.Globalization; namespace MS.Internal { internal static class ResourceIDHelper { // // Convert relative path to the right format which is used // as ResourceID. // MarkupCompiler, ResXGen, Loader will call this method internally. // static internal string GetResourceIDFromRelativePath(string relPath) { // It is important that relPath not contain a fragment or query at this point // // Currently this will always be true because // 1) The resources listed in the .proj file are tested against the filesystem // to see if they exist. If a query or fragment was present this test would fail. // 2) In the new loader the container apis make sure that the fragment and query are // stripped from the Uri to form the part name which is used to load the resource Uri baseUri = new Uri("http://foo/"); Uri srcUri = new Uri(baseUri, relPath.Replace("#", "%23")); return GetResourceIDFromUri(baseUri, srcUri); } // // This is the central place that returns right ResourceID for // the passed SourceUri. // static private string GetResourceIDFromUri(Uri baseUri, Uri sourceUri) { string resourceID = String.Empty; // // Extracts and returns the resource ID from a URI. // If the source URI is under the baseUri, the resource ID is the URI // after the baseUri and any fragment or query has been removed. // The resource ID is always converted to lower case. // // If the sourceUri is not relative to baseUri, Emtpy string is returned // as resource id. // if (baseUri.IsAbsoluteUri == false || sourceUri.IsAbsoluteUri == false) { // // if any passed Uri is not absolute uri, return empty string here. // return resourceID; } if (baseUri.Scheme == sourceUri.Scheme && baseUri.Host == sourceUri.Host) { // // Get the escaped Path part, Path doesn't include Query and Fragment. // string basePath = baseUri.GetComponents(UriComponents.Path, UriFormat.UriEscaped); string sourcePath = sourceUri.GetComponents(UriComponents.Path, UriFormat.UriEscaped); // // Always lower case the Path string. // basePath = basePath.ToLower(CultureInfo.InvariantCulture); sourcePath = sourcePath.ToLower(CultureInfo.InvariantCulture); if (sourcePath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase)) { resourceID = sourcePath.Substring(basePath.Length); } } return resourceID; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Text; using System.Globalization; namespace MS.Internal { internal static class ResourceIDHelper { // // Convert relative path to the right format which is used // as ResourceID. // MarkupCompiler, ResXGen, Loader will call this method internally. // static internal string GetResourceIDFromRelativePath(string relPath) { // It is important that relPath not contain a fragment or query at this point // // Currently this will always be true because // 1) The resources listed in the .proj file are tested against the filesystem // to see if they exist. If a query or fragment was present this test would fail. // 2) In the new loader the container apis make sure that the fragment and query are // stripped from the Uri to form the part name which is used to load the resource Uri baseUri = new Uri("http://foo/"); Uri srcUri = new Uri(baseUri, relPath.Replace("#", "%23")); return GetResourceIDFromUri(baseUri, srcUri); } // // This is the central place that returns right ResourceID for // the passed SourceUri. // static private string GetResourceIDFromUri(Uri baseUri, Uri sourceUri) { string resourceID = String.Empty; // // Extracts and returns the resource ID from a URI. // If the source URI is under the baseUri, the resource ID is the URI // after the baseUri and any fragment or query has been removed. // The resource ID is always converted to lower case. // // If the sourceUri is not relative to baseUri, Emtpy string is returned // as resource id. // if (baseUri.IsAbsoluteUri == false || sourceUri.IsAbsoluteUri == false) { // // if any passed Uri is not absolute uri, return empty string here. // return resourceID; } if (baseUri.Scheme == sourceUri.Scheme && baseUri.Host == sourceUri.Host) { // // Get the escaped Path part, Path doesn't include Query and Fragment. // string basePath = baseUri.GetComponents(UriComponents.Path, UriFormat.UriEscaped); string sourcePath = sourceUri.GetComponents(UriComponents.Path, UriFormat.UriEscaped); // // Always lower case the Path string. // basePath = basePath.ToLower(CultureInfo.InvariantCulture); sourcePath = sourcePath.ToLower(CultureInfo.InvariantCulture); if (sourcePath.StartsWith(basePath, StringComparison.OrdinalIgnoreCase)) { resourceID = sourcePath.Substring(basePath.Length); } } return resourceID; } } } // 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
- FormViewUpdatedEventArgs.cs
- SerializationFieldInfo.cs
- DateTimePicker.cs
- OleDbParameter.cs
- ButtonStandardAdapter.cs
- SmtpFailedRecipientException.cs
- sqlnorm.cs
- sqlstateclientmanager.cs
- LocationUpdates.cs
- GeometryDrawing.cs
- ZipIOModeEnforcingStream.cs
- XmlChildNodes.cs
- TextModifier.cs
- Base64Encoder.cs
- UIElement.cs
- VerticalConnector.xaml.cs
- LoadRetryAsyncResult.cs
- InheritanceContextChangedEventManager.cs
- FixedHighlight.cs
- UserNamePasswordValidator.cs
- Int32RectConverter.cs
- FacetDescriptionElement.cs
- CodeCatchClause.cs
- ContentHostHelper.cs
- ConstantSlot.cs
- RouteItem.cs
- columnmapkeybuilder.cs
- DBDataPermissionAttribute.cs
- UrlAuthorizationModule.cs
- MissingMethodException.cs
- GraphicsContext.cs
- StringHandle.cs
- PopupControlService.cs
- SessionState.cs
- Documentation.cs
- LinqDataSourceContextEventArgs.cs
- QueryCacheManager.cs
- FixedPageProcessor.cs
- CanExecuteRoutedEventArgs.cs
- FormView.cs
- FieldToken.cs
- ErrorFormatterPage.cs
- MdiWindowListStrip.cs
- WizardPanelChangingEventArgs.cs
- BlockUIContainer.cs
- XPathDocument.cs
- ObjectHandle.cs
- DesignerContextDescriptor.cs
- Brushes.cs
- SafeRegistryKey.cs
- SchemaConstraints.cs
- CompiledIdentityConstraint.cs
- XamlSerializerUtil.cs
- ViewGenResults.cs
- TypeUtil.cs
- AccessDataSource.cs
- ElementHostPropertyMap.cs
- IPEndPointCollection.cs
- RegularExpressionValidator.cs
- _RequestLifetimeSetter.cs
- ConnectionManagementElementCollection.cs
- safex509handles.cs
- TransportDefaults.cs
- SystemWebExtensionsSectionGroup.cs
- RelatedView.cs
- MethodBuilder.cs
- TextViewSelectionProcessor.cs
- ResourceSet.cs
- DataObjectMethodAttribute.cs
- PropertyPanel.cs
- SqlException.cs
- WSSecureConversation.cs
- ListDictionaryInternal.cs
- Polyline.cs
- UnionCodeGroup.cs
- TableCellCollection.cs
- _IPv6Address.cs
- StylusPointProperties.cs
- UrlPropertyAttribute.cs
- SelectedCellsChangedEventArgs.cs
- SplitContainerDesigner.cs
- SqlInternalConnection.cs
- ReplyChannel.cs
- BaseDataListPage.cs
- RadioButtonFlatAdapter.cs
- StackSpiller.Temps.cs
- StructuralComparisons.cs
- IListConverters.cs
- BamlTreeNode.cs
- diagnosticsswitches.cs
- ConfigUtil.cs
- WebConfigurationFileMap.cs
- ToolStripMenuItem.cs
- ComponentGlyph.cs
- PropertyEmitter.cs
- InkPresenterAutomationPeer.cs
- XPathAncestorIterator.cs
- ToolTip.cs
- ResourceBinder.cs
- XamlParser.cs