Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- AppLevelCompilationSectionCache.cs
- ConstraintConverter.cs
- _SslState.cs
- BindingMemberInfo.cs
- IncrementalReadDecoders.cs
- ImageDrawing.cs
- WinEventQueueItem.cs
- JavaScriptSerializer.cs
- SolidColorBrush.cs
- QueryComponents.cs
- datacache.cs
- XhtmlBasicLinkAdapter.cs
- Italic.cs
- WebBrowserPermission.cs
- TypeDescriptionProviderAttribute.cs
- NavigationProgressEventArgs.cs
- WebPartDeleteVerb.cs
- MissingMemberException.cs
- IndicCharClassifier.cs
- SqlDelegatedTransaction.cs
- HashHelper.cs
- DateTimeUtil.cs
- Tag.cs
- OleDbWrapper.cs
- Tuple.cs
- InheritanceAttribute.cs
- NullableConverter.cs
- OleStrCAMarshaler.cs
- SQLChars.cs
- SafeProcessHandle.cs
- EFTableProvider.cs
- WebPartDescription.cs
- Claim.cs
- ReferenceConverter.cs
- ProcessThreadCollection.cs
- DashStyle.cs
- CursorConverter.cs
- TdsValueSetter.cs
- FontInfo.cs
- RoutingExtension.cs
- Message.cs
- HandledMouseEvent.cs
- IntSecurity.cs
- NameSpaceEvent.cs
- Soap.cs
- StretchValidation.cs
- IApplicationTrustManager.cs
- ParameterReplacerVisitor.cs
- HiddenField.cs
- Dump.cs
- EnumerableCollectionView.cs
- DirectoryObjectSecurity.cs
- EntityDataSourceWrapper.cs
- HostUtils.cs
- KeyEventArgs.cs
- HelpEvent.cs
- NameValuePermission.cs
- SqlDataSourceSelectingEventArgs.cs
- CallbackValidator.cs
- ProcessModuleDesigner.cs
- SourceFilter.cs
- StringDictionary.cs
- X500Name.cs
- DataGridViewCellFormattingEventArgs.cs
- CompModSwitches.cs
- DataRelation.cs
- SqlBinder.cs
- WinFormsSecurity.cs
- SynchronizedInputAdaptor.cs
- ItemsPanelTemplate.cs
- StringFormat.cs
- DataSourceComponent.cs
- OleDbCommand.cs
- CodeObjectCreateExpression.cs
- GiveFeedbackEvent.cs
- RequestStatusBarUpdateEventArgs.cs
- TypeSystem.cs
- CompilerInfo.cs
- TraceSection.cs
- SemanticResolver.cs
- XmlChildNodes.cs
- FtpCachePolicyElement.cs
- HttpApplication.cs
- ControlBuilderAttribute.cs
- XpsS0ValidatingLoader.cs
- Int64KeyFrameCollection.cs
- PngBitmapEncoder.cs
- FragmentQuery.cs
- DeviceContext.cs
- NGCSerializationManager.cs
- LicenseManager.cs
- Relationship.cs
- PlanCompiler.cs
- RtfControlWordInfo.cs
- XPathParser.cs
- OdbcConnectionFactory.cs
- AspNetCompatibilityRequirementsAttribute.cs
- VectorAnimationBase.cs
- LogicalChannel.cs
- WeakRefEnumerator.cs