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
- WindowsEditBox.cs
- DBConcurrencyException.cs
- Attributes.cs
- TimelineCollection.cs
- WpfPayload.cs
- ComponentResourceManager.cs
- BindingManagerDataErrorEventArgs.cs
- MatrixStack.cs
- UiaCoreApi.cs
- ColorContext.cs
- SectionInformation.cs
- BitmapSource.cs
- LocatorPart.cs
- RenderingEventArgs.cs
- InternalBufferOverflowException.cs
- XmlElementCollection.cs
- RichTextBox.cs
- ContentElement.cs
- SoapAttributeOverrides.cs
- Lasso.cs
- EntityDescriptor.cs
- UpDownBase.cs
- DataGridAddNewRow.cs
- DataMemberAttribute.cs
- DataGridViewRowHeaderCell.cs
- CodeIdentifier.cs
- XsltQilFactory.cs
- ToolStripOverflow.cs
- AsyncOperationManager.cs
- SettingsPropertyValueCollection.cs
- MethodBuilderInstantiation.cs
- TextSegment.cs
- PartitionerQueryOperator.cs
- DataGridViewRowPostPaintEventArgs.cs
- HuffmanTree.cs
- CLSCompliantAttribute.cs
- ListViewItem.cs
- ShaderEffect.cs
- SplitterPanel.cs
- PackWebRequest.cs
- MultiSelectRootGridEntry.cs
- CustomError.cs
- DesigntimeLicenseContextSerializer.cs
- Point3D.cs
- TemplateEditingFrame.cs
- Section.cs
- Coordinator.cs
- MultipartContentParser.cs
- SrgsElementFactory.cs
- ResourceProperty.cs
- CopyOfAction.cs
- XmlSchemaChoice.cs
- EndCreateSecurityTokenRequest.cs
- ControlPaint.cs
- BulletedList.cs
- AttributeCollection.cs
- DispatcherOperation.cs
- SizeAnimationClockResource.cs
- WebMessageEncodingBindingElement.cs
- HelpKeywordAttribute.cs
- ControlDesigner.cs
- BitmapEffectGroup.cs
- DataExpression.cs
- CustomError.cs
- JapaneseLunisolarCalendar.cs
- TrustVersion.cs
- PropertyValueUIItem.cs
- StringToken.cs
- ExpandSegment.cs
- LayoutEditorPart.cs
- X509Certificate.cs
- SqlTransaction.cs
- KerberosSecurityTokenAuthenticator.cs
- XPathScanner.cs
- ConnectionsZone.cs
- MouseActionConverter.cs
- IsolatedStorageFileStream.cs
- FrameDimension.cs
- ConstantCheck.cs
- XmlAtomicValue.cs
- ValueType.cs
- DataControlImageButton.cs
- SpeechUI.cs
- RootBrowserWindowAutomationPeer.cs
- Processor.cs
- UpDownBase.cs
- ConditionCollection.cs
- GetWinFXPath.cs
- HtmlInputReset.cs
- Int32RectValueSerializer.cs
- PrintSchema.cs
- SapiRecoContext.cs
- RequestContext.cs
- EmissiveMaterial.cs
- CodeGenerationManager.cs
- XmlSerializerAssemblyAttribute.cs
- LogicalChannelCollection.cs
- AccessDataSource.cs
- ThreadStateException.cs
- RecognizeCompletedEventArgs.cs