Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / System / Windows / Media / TypeConverterHelper.cs / 1305600 / TypeConverterHelper.cs
//------------------------------------------------------------------------------ // Microsoft Avalon // Copyright (c) Microsoft Corporation, All rights reserved. // // File: TypeConverterHelper.cs // //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.ComponentModel; using System.Windows.Markup; using System.Runtime.InteropServices; using System.Windows.Navigation; namespace System.Windows.Media { #region UriHolder ////// UriHolder /// Holds Original and Base Uris /// [StructLayout(LayoutKind.Sequential, Pack=1)] internal struct UriHolder { ////// BaseUri /// internal Uri BaseUri; ///Can be null ////// OriginalUri /// internal Uri OriginalUri; }; #endregion #region TypeConverterHelper ////// This helper method is used primarily by type converters to resolve their uri /// ////// There are three scenarios that can happen: /// /// 1) inputString is an absolute uri -- we return it as the resolvedUri /// 2) inputString is not absolute: /// i) the relativeBaseUri (obtained from IUriContext) has the following values: /// a) is an absolute uri, we use relativeBaseUri as base uri and resolve /// the inputString against it /// /// b) is a relative uri, we use Application's base uri (obtained from /// BindUriHelperCore.BaseUri) as the base and resolve the relativeBaseUri /// against it; furthermore, we resolve the inputString against with uri /// obtained from the application base resolution. /// /// c) is "", we resolve inputString against the Application's base uri /// internal static class TypeConverterHelper { internal static UriHolder GetUriFromUriContext(ITypeDescriptorContext context, object inputString) { UriHolder uriHolder = new UriHolder(); if (inputString is string) { uriHolder.OriginalUri = new Uri((string)inputString, UriKind.RelativeOrAbsolute); } else { Debug.Assert(inputString is Uri); uriHolder.OriginalUri = (Uri)inputString; } if (uriHolder.OriginalUri.IsAbsoluteUri == false) { //Debug.Assert (context != null, "Context should not be null"); if (context != null) { IUriContext iuc = (IUriContext)context.GetService(typeof(IUriContext)); //Debug.Assert (iuc != null, "IUriContext should not be null here"); if (iuc != null) { // the base uri is NOT "" if (iuc.BaseUri != null) { uriHolder.BaseUri = iuc.BaseUri; if (!uriHolder.BaseUri.IsAbsoluteUri) { uriHolder.BaseUri = new Uri(BaseUriHelper.BaseUri, uriHolder.BaseUri); } } // uriHolder.BaseUriString != "" else { // if we reach here, the base uri we got from IUriContext is "" // and the inputString is a relative uri. Here we resolve it to // application's base uriHolder.BaseUri = BaseUriHelper.BaseUri; } } // iuc != null } // context!= null } // uriHolder.OriginalUri.IsAbsoluteUri == false return uriHolder; } } #endregion } // 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
- SystemIcmpV4Statistics.cs
- SortExpressionBuilder.cs
- DesignerTransaction.cs
- SoapRpcServiceAttribute.cs
- ISAPIRuntime.cs
- DataGridItem.cs
- TraceEventCache.cs
- UnsafeNativeMethods.cs
- ParameterSubsegment.cs
- DataGridViewRowStateChangedEventArgs.cs
- PatternMatchRules.cs
- TraceSection.cs
- mactripleDES.cs
- DataGridViewRowHeaderCell.cs
- DBConnection.cs
- WriteTimeStream.cs
- HttpHandlerAction.cs
- HMACSHA1.cs
- IOThreadTimer.cs
- DocumentViewerBaseAutomationPeer.cs
- AssociationSetEnd.cs
- MemberRelationshipService.cs
- SignatureResourcePool.cs
- LazyTextWriterCreator.cs
- EntityStoreSchemaGenerator.cs
- SwitchElementsCollection.cs
- EmptyReadOnlyDictionaryInternal.cs
- ParallelQuery.cs
- AdjustableArrowCap.cs
- WebPartVerbCollection.cs
- ConnectionsZone.cs
- DependencyObject.cs
- isolationinterop.cs
- DeferrableContentConverter.cs
- RuleCache.cs
- DataViewManagerListItemTypeDescriptor.cs
- CallTemplateAction.cs
- SystemIcmpV6Statistics.cs
- UserControl.cs
- StrongNamePublicKeyBlob.cs
- ShaderEffect.cs
- DirectoryObjectSecurity.cs
- LiteralControl.cs
- IconBitmapDecoder.cs
- HandledMouseEvent.cs
- MissingFieldException.cs
- WorkflowHostingEndpoint.cs
- ProtocolViolationException.cs
- Win32Interop.cs
- StringReader.cs
- DSASignatureFormatter.cs
- ThicknessAnimation.cs
- ListViewUpdatedEventArgs.cs
- SecUtil.cs
- HandlerWithFactory.cs
- PackageDigitalSignatureManager.cs
- MenuAutoFormat.cs
- XmlComment.cs
- RootBrowserWindow.cs
- Transform.cs
- SurrogateEncoder.cs
- RegexWorker.cs
- NoneExcludedImageIndexConverter.cs
- XmlException.cs
- UIElementHelper.cs
- XmlSchemaGroup.cs
- WizardStepBase.cs
- EventTrigger.cs
- CollectionBuilder.cs
- Style.cs
- CodeCastExpression.cs
- SiteOfOriginContainer.cs
- UIElement3D.cs
- DependencyProperty.cs
- HttpCookieCollection.cs
- FontWeights.cs
- CharStorage.cs
- SafeWaitHandle.cs
- Document.cs
- SafeBitVector32.cs
- TextServicesPropertyRanges.cs
- TypeRestriction.cs
- JsonReaderDelegator.cs
- BamlLocalizableResourceKey.cs
- ValueUtilsSmi.cs
- XmlParser.cs
- ContextConfiguration.cs
- Double.cs
- ToolConsole.cs
- EntityExpressionVisitor.cs
- PartialArray.cs
- NegotiateStream.cs
- SafeFileHandle.cs
- DSASignatureFormatter.cs
- QueryCacheKey.cs
- LocalizableResourceBuilder.cs
- SmtpMail.cs
- OverflowException.cs
- BitVec.cs
- WindowsSolidBrush.cs