Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DependencySource.cs
- BitmapEffectGeneralTransform.cs
- DatePicker.cs
- MarkupObject.cs
- ImageSourceValueSerializer.cs
- SemanticResultValue.cs
- XmlJsonReader.cs
- FileDataSourceCache.cs
- XmlNodeList.cs
- ReachPrintTicketSerializerAsync.cs
- DrawingContextDrawingContextWalker.cs
- CompatibleComparer.cs
- SelectionItemPattern.cs
- JoinGraph.cs
- TableCellCollection.cs
- RSAOAEPKeyExchangeFormatter.cs
- Set.cs
- CssTextWriter.cs
- Storyboard.cs
- BatchStream.cs
- ClientTarget.cs
- PeerInvitationResponse.cs
- CodeDirectiveCollection.cs
- CodeObject.cs
- InputLanguage.cs
- DataBoundControlParameterTarget.cs
- EnumValAlphaComparer.cs
- HttpContextServiceHost.cs
- UpdateRecord.cs
- MonthChangedEventArgs.cs
- ICspAsymmetricAlgorithm.cs
- QueryableDataSourceView.cs
- ExpressionVisitorHelpers.cs
- Command.cs
- Canvas.cs
- SQLDecimal.cs
- XmlSchemaIdentityConstraint.cs
- PersianCalendar.cs
- MatrixTransform.cs
- TextInfo.cs
- TransformerInfo.cs
- _MultipleConnectAsync.cs
- Panel.cs
- FormsAuthenticationUser.cs
- RotateTransform3D.cs
- XpsInterleavingPolicy.cs
- DefaultDialogButtons.cs
- SettingsSavedEventArgs.cs
- DataGridCell.cs
- TimerElapsedEvenArgs.cs
- RadioButtonFlatAdapter.cs
- _TLSstream.cs
- SqlTypeSystemProvider.cs
- AsymmetricKeyExchangeFormatter.cs
- printdlgexmarshaler.cs
- InvalidDataContractException.cs
- NotifyCollectionChangedEventArgs.cs
- DataGridColumn.cs
- TextDecoration.cs
- String.cs
- ServiceModelConfigurationSectionGroup.cs
- SqlBulkCopy.cs
- DataBinder.cs
- XmlILOptimizerVisitor.cs
- EntityDataSourceDataSelectionPanel.designer.cs
- DiscoveryDefaults.cs
- SafeHandles.cs
- EntityDataSourceDataSelection.cs
- PageWrapper.cs
- ChangePasswordAutoFormat.cs
- CurrentTimeZone.cs
- DoWorkEventArgs.cs
- HwndTarget.cs
- GridViewUpdatedEventArgs.cs
- ImageAnimator.cs
- InstallHelper.cs
- CompositeDataBoundControl.cs
- DataSourceCache.cs
- StickyNote.cs
- ObsoleteAttribute.cs
- RegistrySecurity.cs
- BaseComponentEditor.cs
- PropertyToken.cs
- Lock.cs
- BasicCellRelation.cs
- PluralizationService.cs
- InstanceCollisionException.cs
- RelationshipConverter.cs
- MarkedHighlightComponent.cs
- PageThemeCodeDomTreeGenerator.cs
- PageOutputQuality.cs
- Resources.Designer.cs
- DataSet.cs
- SQLCharsStorage.cs
- TableLayoutRowStyleCollection.cs
- JsonWriter.cs
- WorkingDirectoryEditor.cs
- BrowserCapabilitiesCodeGenerator.cs
- ConfigurationStrings.cs
- OdbcUtils.cs