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
- UInt32Storage.cs
- PixelShader.cs
- SmtpException.cs
- NavigationHelper.cs
- HtmlTableRow.cs
- DynamicRenderer.cs
- EraserBehavior.cs
- Pens.cs
- SymLanguageVendor.cs
- ParallelTimeline.cs
- StringDictionaryWithComparer.cs
- _AutoWebProxyScriptHelper.cs
- NetworkInformationException.cs
- coordinatorscratchpad.cs
- MdImport.cs
- PixelFormats.cs
- HtmlUtf8RawTextWriter.cs
- DataControlFieldHeaderCell.cs
- DynamicEndpoint.cs
- SchemaImporterExtensionElementCollection.cs
- Parser.cs
- NavigationPropertyEmitter.cs
- EntityContainerRelationshipSet.cs
- ObjectDataSourceDisposingEventArgs.cs
- XmlObjectSerializerContext.cs
- ColumnHeader.cs
- Selection.cs
- SoapWriter.cs
- CroppedBitmap.cs
- HotSpotCollectionEditor.cs
- Attributes.cs
- ByteStream.cs
- BaseCodePageEncoding.cs
- PathGeometry.cs
- PropertyDescriptorComparer.cs
- MobileControlPersister.cs
- ConfigurationManagerHelperFactory.cs
- EqualityComparer.cs
- CodeCommentStatement.cs
- SafeNativeMemoryHandle.cs
- DiscoveryServerProtocol.cs
- StandardRuntimeEnumValidator.cs
- ChannelTraceRecord.cs
- Stroke2.cs
- XmlFormatWriterGenerator.cs
- DeviceSpecificDesigner.cs
- ItemAutomationPeer.cs
- FileDialogCustomPlacesCollection.cs
- WindowsComboBox.cs
- CallbackValidatorAttribute.cs
- MissingMethodException.cs
- RectValueSerializer.cs
- ArrangedElementCollection.cs
- AuthenticationSection.cs
- IteratorDescriptor.cs
- ScrollPattern.cs
- HttpCacheVary.cs
- TriState.cs
- RectAnimation.cs
- ProxyRpc.cs
- CodeArrayIndexerExpression.cs
- ObjectQueryState.cs
- WebPartZone.cs
- AssemblyCollection.cs
- DependencyPropertyValueSerializer.cs
- SmiMetaData.cs
- ValidatorAttribute.cs
- TreeChangeInfo.cs
- ValueQuery.cs
- CodeIndexerExpression.cs
- SchemaMapping.cs
- DataBindingCollection.cs
- SettingsContext.cs
- ElementAction.cs
- TargetException.cs
- Calendar.cs
- RemoteWebConfigurationHostServer.cs
- XmlCharacterData.cs
- TdsParameterSetter.cs
- AxHost.cs
- SequentialWorkflowRootDesigner.cs
- CompatibleComparer.cs
- EntityDataSourceReferenceGroup.cs
- DesignerActionVerbItem.cs
- __Filters.cs
- Point3DConverter.cs
- ObjectManager.cs
- DateTimeParse.cs
- RegexCharClass.cs
- UMPAttributes.cs
- BezierSegment.cs
- StaticExtension.cs
- RegistryConfigurationProvider.cs
- WpfXamlMember.cs
- RecognitionResult.cs
- MetadataExporter.cs
- XamlPointCollectionSerializer.cs
- Property.cs
- GetCertificateRequest.cs
- Label.cs