Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- LinearKeyFrames.cs
- MdImport.cs
- OuterGlowBitmapEffect.cs
- JournalEntry.cs
- SelectiveScrollingGrid.cs
- KeyedCollection.cs
- DisplayNameAttribute.cs
- ColorAnimationBase.cs
- CasesDictionary.cs
- KeyPressEvent.cs
- InProcStateClientManager.cs
- filewebrequest.cs
- Image.cs
- DataReceivedEventArgs.cs
- XmlHierarchyData.cs
- controlskin.cs
- GeneratedContractType.cs
- XomlCompilerError.cs
- PropertyPushdownHelper.cs
- CustomExpressionEventArgs.cs
- CancellationHandlerDesigner.cs
- ConditionalAttribute.cs
- DrawingImage.cs
- BinaryFormatterWriter.cs
- TransformValueSerializer.cs
- StatusBarPanel.cs
- CombinedGeometry.cs
- AuthorizationPolicyTypeElementCollection.cs
- SplitContainer.cs
- ResourceManager.cs
- ReadOnlyDictionary.cs
- RadialGradientBrush.cs
- SafeRegistryHandle.cs
- ResourceAssociationSetEnd.cs
- BinHexEncoder.cs
- XmlValidatingReader.cs
- util.cs
- ConfigurationConverterBase.cs
- ProxyFragment.cs
- PipelineModuleStepContainer.cs
- TaskFileService.cs
- WinFormsComponentEditor.cs
- BinaryReader.cs
- RtfControlWordInfo.cs
- StrongNameKeyPair.cs
- TypeReference.cs
- CheckBoxBaseAdapter.cs
- TypeKeyValue.cs
- PageOrientation.cs
- SortedList.cs
- HuffmanTree.cs
- TableCellCollection.cs
- NotSupportedException.cs
- ClientSession.cs
- X509Certificate2Collection.cs
- NetworkInformationPermission.cs
- SqlProviderManifest.cs
- WindowsToolbarAsMenu.cs
- HMACSHA256.cs
- ArgumentOutOfRangeException.cs
- PieceDirectory.cs
- srgsitem.cs
- TrackBarRenderer.cs
- COM2PictureConverter.cs
- StateFinalizationDesigner.cs
- EntityException.cs
- Size3D.cs
- DbConnectionPoolCounters.cs
- InputBinder.cs
- RawMouseInputReport.cs
- StorageMappingItemLoader.cs
- RijndaelManagedTransform.cs
- ClientProtocol.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- WebPartHeaderCloseVerb.cs
- DataGridRelationshipRow.cs
- UpdatePanelTrigger.cs
- QilXmlReader.cs
- ProviderUtil.cs
- SafeRightsManagementQueryHandle.cs
- XmlWhitespace.cs
- XmlSerializerNamespaces.cs
- VersionedStream.cs
- FixedTextView.cs
- SerialStream.cs
- diagnosticsswitches.cs
- AssemblyAttributesGoHere.cs
- counter.cs
- ListItemCollection.cs
- ListViewSortEventArgs.cs
- SetterBaseCollection.cs
- ValidationError.cs
- ColorInterpolationModeValidation.cs
- GradientStop.cs
- MetadataCollection.cs
- XmlDataLoader.cs
- MailDefinition.cs
- SqlDependencyListener.cs
- HttpModulesSection.cs
- SoapServerMessage.cs