Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- Queue.cs
- XmlBoundElement.cs
- CodeDirectiveCollection.cs
- PersonalizationDictionary.cs
- TextTreePropertyUndoUnit.cs
- InteropBitmapSource.cs
- HTTPNotFoundHandler.cs
- Rijndael.cs
- _ListenerAsyncResult.cs
- BrowserDefinitionCollection.cs
- SectionUpdates.cs
- EpmSyndicationContentSerializer.cs
- GeometryConverter.cs
- Int16AnimationBase.cs
- MissingMemberException.cs
- PriorityBindingExpression.cs
- ByteConverter.cs
- DataRow.cs
- XmlRawWriterWrapper.cs
- UInt32Converter.cs
- cache.cs
- DragEvent.cs
- NativeObjectSecurity.cs
- DesignerObjectListAdapter.cs
- RenderingBiasValidation.cs
- XmlSiteMapProvider.cs
- SmiXetterAccessMap.cs
- SqlDependencyUtils.cs
- ServiceOperationParameter.cs
- DesignConnectionCollection.cs
- DataSourceCacheDurationConverter.cs
- OracleColumn.cs
- StructuralCache.cs
- WindowAutomationPeer.cs
- MobileControlBuilder.cs
- EditableTreeList.cs
- ProbeDuplex11AsyncResult.cs
- HttpCacheVaryByContentEncodings.cs
- Subtree.cs
- SmtpReplyReader.cs
- ResXBuildProvider.cs
- EventLogEntryCollection.cs
- TextOptions.cs
- EventItfInfo.cs
- CommonProperties.cs
- TransferRequestHandler.cs
- WSFederationHttpSecurityElement.cs
- RowBinding.cs
- DBConnectionString.cs
- HashAlgorithm.cs
- OleDbCommandBuilder.cs
- AnnotationService.cs
- Vector3DAnimationBase.cs
- SettingsProperty.cs
- NativeRecognizer.cs
- SystemIPAddressInformation.cs
- OdbcParameter.cs
- GlyphInfoList.cs
- FrameworkContextData.cs
- SessionStateModule.cs
- Int64Storage.cs
- TypeUtil.cs
- DetectRunnableInstancesTask.cs
- CodeDomConfigurationHandler.cs
- WindowsTitleBar.cs
- DataControlFieldHeaderCell.cs
- NamespaceInfo.cs
- ImageListImageEditor.cs
- SaveFileDialog.cs
- AspNetSynchronizationContext.cs
- dbdatarecord.cs
- AdjustableArrowCap.cs
- Geometry3D.cs
- MSG.cs
- WebPartConnectionsCancelEventArgs.cs
- LinqDataSourceEditData.cs
- ReflectionHelper.cs
- FilePrompt.cs
- FormCollection.cs
- MergeFailedEvent.cs
- ClientSettingsProvider.cs
- TableAutomationPeer.cs
- AsymmetricCryptoHandle.cs
- SchemaLookupTable.cs
- ListSortDescription.cs
- ParentQuery.cs
- AccessibleObject.cs
- LocalizableAttribute.cs
- ContractDescription.cs
- FolderLevelBuildProvider.cs
- ReadWriteSpinLock.cs
- FormViewRow.cs
- Command.cs
- DurableInstanceProvider.cs
- DefaultObjectSerializer.cs
- DesignerAdapterUtil.cs
- safelinkcollection.cs
- TextTreeRootNode.cs
- MinMaxParagraphWidth.cs
- DefaultBinder.cs