Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / WebBrowserUriTypeConverter.cs / 1 / WebBrowserUriTypeConverter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.ComponentModel; namespace System.Windows.Forms { class WebBrowserUriTypeConverter : UriTypeConverter { public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { //The UriTypeConverter gives back a relative Uri for things like "www.microsoft.com". If //the Uri is relative, we'll try sticking "http://" on the front to see whether that fixes it up. Uri uri = base.ConvertFrom(context, culture, value) as Uri; if (uri != null && !string.IsNullOrEmpty(uri.OriginalString) && !uri.IsAbsoluteUri) { try { uri = new Uri("http://" + uri.OriginalString.Trim()); } catch (UriFormatException) { //We can't throw "http://" on the front: just return the original (relative) Uri, //which will throw an exception with reasonable text later. } } return uri; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.ComponentModel; namespace System.Windows.Forms { class WebBrowserUriTypeConverter : UriTypeConverter { public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { //The UriTypeConverter gives back a relative Uri for things like "www.microsoft.com". If //the Uri is relative, we'll try sticking "http://" on the front to see whether that fixes it up. Uri uri = base.ConvertFrom(context, culture, value) as Uri; if (uri != null && !string.IsNullOrEmpty(uri.OriginalString) && !uri.IsAbsoluteUri) { try { uri = new Uri("http://" + uri.OriginalString.Trim()); } catch (UriFormatException) { //We can't throw "http://" on the front: just return the original (relative) Uri, //which will throw an exception with reasonable text later. } } return uri; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SelectionItemProviderWrapper.cs
- XmlSerializerVersionAttribute.cs
- DownloadProgressEventArgs.cs
- IERequestCache.cs
- GiveFeedbackEventArgs.cs
- IndexingContentUnit.cs
- TextRenderingModeValidation.cs
- TypeConverter.cs
- ChannelAcceptor.cs
- HttpRequestTraceRecord.cs
- XmlTextWriter.cs
- HandlerBase.cs
- DynamicMethod.cs
- RequestBringIntoViewEventArgs.cs
- X509SecurityToken.cs
- XmlNamespaceManager.cs
- XmlObjectSerializerWriteContext.cs
- ServiceModelEnumValidator.cs
- ResourcePermissionBase.cs
- Html32TextWriter.cs
- ConfigXmlText.cs
- ConnectionsZone.cs
- AdRotator.cs
- SystemUnicastIPAddressInformation.cs
- DefaultValueConverter.cs
- TailCallAnalyzer.cs
- IsolatedStoragePermission.cs
- InvariantComparer.cs
- DataAdapter.cs
- DrawingAttributes.cs
- AtomicFile.cs
- BooleanFunctions.cs
- ZipFileInfoCollection.cs
- TableLayoutSettings.cs
- XMLDiffLoader.cs
- coordinatorfactory.cs
- StaticContext.cs
- coordinatorfactory.cs
- XmlName.cs
- ImmutableAssemblyCacheEntry.cs
- FixedPageStructure.cs
- wmiprovider.cs
- GeometryHitTestParameters.cs
- Highlights.cs
- InstanceOwnerException.cs
- FormsAuthenticationModule.cs
- UnsafeNativeMethods.cs
- PointCollectionConverter.cs
- XmlEncodedRawTextWriter.cs
- ArcSegment.cs
- BaseDataList.cs
- Transform3D.cs
- ConnectionPoint.cs
- HttpCapabilitiesEvaluator.cs
- StatusBarItem.cs
- DatePicker.cs
- FontNamesConverter.cs
- FixedPageStructure.cs
- AssociationSetEnd.cs
- _StreamFramer.cs
- AxHost.cs
- SimpleLine.cs
- EmbeddedMailObject.cs
- BindStream.cs
- PageParser.cs
- Constants.cs
- BindingContext.cs
- ShaderRenderModeValidation.cs
- InputScopeConverter.cs
- ValidationErrorCollection.cs
- Rotation3DAnimation.cs
- MimeTypeMapper.cs
- MenuItemStyleCollectionEditor.cs
- HostedElements.cs
- XPathDescendantIterator.cs
- XmlSchemaSimpleContent.cs
- QilInvokeEarlyBound.cs
- InputMethodStateChangeEventArgs.cs
- XpsFont.cs
- Site.cs
- Panel.cs
- Label.cs
- ForceCopyBuildProvider.cs
- ValidatingReaderNodeData.cs
- SelectionWordBreaker.cs
- DataControlCommands.cs
- ExpandedWrapper.cs
- EllipseGeometry.cs
- GridViewCommandEventArgs.cs
- _NegoState.cs
- EndOfStreamException.cs
- XNodeNavigator.cs
- BindingManagerDataErrorEventArgs.cs
- XmlComplianceUtil.cs
- IPPacketInformation.cs
- EncoderReplacementFallback.cs
- RSACryptoServiceProvider.cs
- SoapMessage.cs
- SoapEnumAttribute.cs
- WindowsRebar.cs