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
- _LoggingObject.cs
- SafeNativeMethods.cs
- ProfileSection.cs
- ModelPropertyCollectionImpl.cs
- _FtpControlStream.cs
- SqlCacheDependencySection.cs
- WsdlBuildProvider.cs
- ListItemViewAttribute.cs
- Operators.cs
- FileRecordSequence.cs
- ComponentDispatcher.cs
- MessageQueueAccessControlEntry.cs
- EditorBrowsableAttribute.cs
- RegisteredExpandoAttribute.cs
- FrugalList.cs
- SmtpCommands.cs
- OpenFileDialog.cs
- RewritingSimplifier.cs
- EventProviderWriter.cs
- ManipulationStartedEventArgs.cs
- ColumnWidthChangingEvent.cs
- TextViewSelectionProcessor.cs
- OleDbSchemaGuid.cs
- GridViewPageEventArgs.cs
- Dump.cs
- SessionPageStateSection.cs
- CustomErrorsSection.cs
- TextPointerBase.cs
- BulletedListDesigner.cs
- AsymmetricAlgorithm.cs
- SplineKeyFrames.cs
- CqlParserHelpers.cs
- LogicalMethodInfo.cs
- DecoderNLS.cs
- ChameleonKey.cs
- CodeIdentifier.cs
- StylusTip.cs
- MsmqInputChannelBase.cs
- ButtonPopupAdapter.cs
- XmlAttributeAttribute.cs
- ActiveXContainer.cs
- OwnerDrawPropertyBag.cs
- PersistenceProviderElement.cs
- ControlCommandSet.cs
- UdpTransportSettings.cs
- CorrelationManager.cs
- WebPartActionVerb.cs
- EncoderExceptionFallback.cs
- GenerateHelper.cs
- DataGridViewRowEventArgs.cs
- odbcmetadatacolumnnames.cs
- ListControl.cs
- DbConnectionPoolCounters.cs
- BaseParagraph.cs
- WindowsListViewItemCheckBox.cs
- FormsAuthenticationEventArgs.cs
- DataControlCommands.cs
- VerifyHashRequest.cs
- DBCommand.cs
- ISCIIEncoding.cs
- ResXDataNode.cs
- CustomLineCap.cs
- TextBoxDesigner.cs
- IncrementalCompileAnalyzer.cs
- XslAstAnalyzer.cs
- ServiceModelEnumValidator.cs
- PassportAuthenticationEventArgs.cs
- AppearanceEditorPart.cs
- XappLauncher.cs
- ContainerParaClient.cs
- HybridDictionary.cs
- UnsafeNativeMethods.cs
- DuplicateWaitObjectException.cs
- backend.cs
- CommonXSendMessage.cs
- UDPClient.cs
- DependencyPropertyDescriptor.cs
- DynamicVirtualDiscoSearcher.cs
- XslTransform.cs
- HttpPostedFile.cs
- ScalarRestriction.cs
- messageonlyhwndwrapper.cs
- WindowsRichEdit.cs
- WithParamAction.cs
- SqlGatherConsumedAliases.cs
- CipherData.cs
- WorkflowServiceNamespace.cs
- Stacktrace.cs
- PenLineJoinValidation.cs
- TextComposition.cs
- SoapReflectionImporter.cs
- CompoundFileDeflateTransform.cs
- HScrollProperties.cs
- figurelength.cs
- RoutedEventArgs.cs
- TreeNodeCollectionEditorDialog.cs
- HttpTransportManager.cs
- WorkflowNamespace.cs
- UidManager.cs
- TextTreeText.cs