Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UniqueConstraint.cs
- KnownBoxes.cs
- PageSetupDialog.cs
- HtmlButton.cs
- ExpandSegment.cs
- QueryStringParameter.cs
- XPathDescendantIterator.cs
- TextEditorCopyPaste.cs
- UntypedNullExpression.cs
- _SslSessionsCache.cs
- DataViewListener.cs
- GradientBrush.cs
- ColumnHeaderConverter.cs
- XmlParser.cs
- ComponentSerializationService.cs
- ProcessModelSection.cs
- SwitchElementsCollection.cs
- GroupItemAutomationPeer.cs
- RotateTransform.cs
- DBSqlParserColumn.cs
- OSFeature.cs
- DependencyPropertyChangedEventArgs.cs
- BmpBitmapEncoder.cs
- GcSettings.cs
- StorageTypeMapping.cs
- UnsafeNativeMethods.cs
- SchemaImporterExtensionsSection.cs
- TypeInfo.cs
- MediaTimeline.cs
- HttpHandlersSection.cs
- ICspAsymmetricAlgorithm.cs
- ArcSegment.cs
- ElementNotAvailableException.cs
- SymmetricCryptoHandle.cs
- ComponentEditorPage.cs
- EventEntry.cs
- Odbc32.cs
- VBCodeProvider.cs
- NullExtension.cs
- ExpressionsCollectionConverter.cs
- FormViewPagerRow.cs
- ServiceHttpModule.cs
- ObjectQueryExecutionPlan.cs
- ResourceProviderFactory.cs
- FileUtil.cs
- UserNameServiceElement.cs
- AdornerLayer.cs
- ImageAutomationPeer.cs
- BrowserDefinition.cs
- ListChangedEventArgs.cs
- WindowsFormsHostAutomationPeer.cs
- BamlLocalizer.cs
- IUnknownConstantAttribute.cs
- ConfigurationValidatorBase.cs
- TrustSection.cs
- ProfileInfo.cs
- BindingList.cs
- MiniCustomAttributeInfo.cs
- FileClassifier.cs
- UnsafeNativeMethods.cs
- MediaContextNotificationWindow.cs
- XmlChildEnumerator.cs
- Substitution.cs
- ColorContext.cs
- DataGridBoolColumn.cs
- SplitterCancelEvent.cs
- MonikerUtility.cs
- TextStore.cs
- DocumentStatusResources.cs
- FlowDocumentReader.cs
- Opcode.cs
- input.cs
- XmlSchemaNotation.cs
- HierarchicalDataTemplate.cs
- TextPattern.cs
- SmtpSection.cs
- MetaData.cs
- RtfControls.cs
- MDIWindowDialog.cs
- RefreshEventArgs.cs
- NativeMethods.cs
- SystemGatewayIPAddressInformation.cs
- DrawingAttributeSerializer.cs
- FormatVersion.cs
- Quaternion.cs
- HtmlLink.cs
- DataGridViewDataConnection.cs
- ItemCollection.cs
- GroupDescription.cs
- TargetPerspective.cs
- FontStretchConverter.cs
- QueryConverter.cs
- ConnectorDragDropGlyph.cs
- DataGridViewTopLeftHeaderCell.cs
- JapaneseCalendar.cs
- EventPrivateKey.cs
- Rotation3DAnimation.cs
- CompilerGeneratedAttribute.cs
- ExecutionScope.cs
- KeySplineConverter.cs