Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Shared / MS / Internal / ResourceIDHelper.cs / 1 / 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
- Scalars.cs
- ComplexBindingPropertiesAttribute.cs
- WebServiceErrorEvent.cs
- SendingRequestEventArgs.cs
- Stream.cs
- SmiEventStream.cs
- ValueConversionAttribute.cs
- ClientType.cs
- BufferAllocator.cs
- WindowsBrush.cs
- TrackingConditionCollection.cs
- Page.cs
- MetaType.cs
- SupportingTokenChannel.cs
- PointAnimationUsingKeyFrames.cs
- TextDecorationLocationValidation.cs
- HelloMessage11.cs
- SiblingIterators.cs
- DrawingContextDrawingContextWalker.cs
- DataGridViewButtonCell.cs
- wgx_exports.cs
- MetadataItemSerializer.cs
- HwndKeyboardInputProvider.cs
- SoapFormatter.cs
- System.Data_BID.cs
- ProcessHostFactoryHelper.cs
- PerspectiveCamera.cs
- ColorAnimationUsingKeyFrames.cs
- DataRelation.cs
- FontWeights.cs
- MouseActionConverter.cs
- HttpCapabilitiesSectionHandler.cs
- PropertyManager.cs
- MatrixValueSerializer.cs
- Button.cs
- WebPartCatalogAddVerb.cs
- AsyncDataRequest.cs
- HierarchicalDataTemplate.cs
- DataGrid.cs
- XmlAttributeProperties.cs
- AppSettingsSection.cs
- SqlUnionizer.cs
- UserNameSecurityTokenAuthenticator.cs
- PartBasedPackageProperties.cs
- ColorTransform.cs
- DirectionalLight.cs
- log.cs
- RSAPKCS1KeyExchangeFormatter.cs
- EntityClientCacheKey.cs
- SimpleFieldTemplateFactory.cs
- ErrorStyle.cs
- XsltException.cs
- WSMessageEncoding.cs
- Selector.cs
- WebPartTransformerCollection.cs
- SubMenuStyle.cs
- StylusDevice.cs
- PrintDocument.cs
- StyleHelper.cs
- RedistVersionInfo.cs
- ExtensionDataReader.cs
- GlyphTypeface.cs
- OutputCacheProviderCollection.cs
- OLEDB_Util.cs
- ObservableCollection.cs
- ExclusiveTcpListener.cs
- FlowLayoutPanelDesigner.cs
- ASCIIEncoding.cs
- KnownColorTable.cs
- TreeView.cs
- DbParameterHelper.cs
- PeerTransportListenAddressValidatorAttribute.cs
- ISAPIApplicationHost.cs
- SettingsAttributes.cs
- DiscreteKeyFrames.cs
- SqlRewriteScalarSubqueries.cs
- MetadataAssemblyHelper.cs
- XmlObjectSerializerContext.cs
- DesignSurfaceServiceContainer.cs
- XmlEnumAttribute.cs
- ServiceRoute.cs
- EventWaitHandleSecurity.cs
- MinimizableAttributeTypeConverter.cs
- ObjectParameter.cs
- SymbolTable.cs
- HitTestDrawingContextWalker.cs
- DataViewSetting.cs
- OverrideMode.cs
- ActionMessageFilterTable.cs
- XpsFixedDocumentReaderWriter.cs
- Parameter.cs
- ConnectorEditor.cs
- XmlDataSourceView.cs
- BaseAppDomainProtocolHandler.cs
- ChangePassword.cs
- ParameterCollectionEditor.cs
- RequestCacheEntry.cs
- MailMessage.cs
- GridViewCommandEventArgs.cs
- ChangeDirector.cs