Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / WebBrowserUriTypeConverter.cs / 1305376 / 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
- xmlsaver.cs
- PhysicalOps.cs
- OdbcStatementHandle.cs
- InvalidFilterCriteriaException.cs
- XmlWriterSettings.cs
- PixelFormatConverter.cs
- DataTableNameHandler.cs
- basecomparevalidator.cs
- SecurityToken.cs
- ObjectStorage.cs
- XmlArrayItemAttribute.cs
- KoreanCalendar.cs
- WebExceptionStatus.cs
- HyperLinkField.cs
- MapPathBasedVirtualPathProvider.cs
- UmAlQuraCalendar.cs
- GridViewCellAutomationPeer.cs
- SharedPersonalizationStateInfo.cs
- IncrementalReadDecoders.cs
- ImageMapEventArgs.cs
- SqlCharStream.cs
- WebConfigurationHostFileChange.cs
- TriggerCollection.cs
- DynamicUpdateCommand.cs
- Debugger.cs
- DecoderNLS.cs
- ClonableStack.cs
- CapabilitiesPattern.cs
- CornerRadiusConverter.cs
- XmlSchemaObjectTable.cs
- entityreference_tresulttype.cs
- KnownBoxes.cs
- ProtocolsConfigurationEntry.cs
- XamlFrame.cs
- PageContentCollection.cs
- NetNamedPipeSecurity.cs
- IsolatedStoragePermission.cs
- OutgoingWebResponseContext.cs
- HMACSHA384.cs
- SoapAttributeOverrides.cs
- FillBehavior.cs
- MasterPageCodeDomTreeGenerator.cs
- assertwrapper.cs
- XNodeNavigator.cs
- SectionInput.cs
- InvokeProviderWrapper.cs
- Pipe.cs
- infer.cs
- WebResourceAttribute.cs
- ReceiveActivityDesignerTheme.cs
- FontUnitConverter.cs
- AccessText.cs
- SqlProviderManifest.cs
- SpAudioStreamWrapper.cs
- FSWPathEditor.cs
- TripleDESCryptoServiceProvider.cs
- SqlUDTStorage.cs
- TableRowGroup.cs
- FontInfo.cs
- ProgressBar.cs
- QueryOptionExpression.cs
- EventLogPermission.cs
- RequestBringIntoViewEventArgs.cs
- MailFileEditor.cs
- DataControlReference.cs
- PageThemeCodeDomTreeGenerator.cs
- CodeMemberField.cs
- CompilerGeneratedAttribute.cs
- ImageListUtils.cs
- MailAddressCollection.cs
- VariantWrapper.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- ListSortDescription.cs
- XmlDataSourceView.cs
- ComponentCommands.cs
- ButtonBase.cs
- MemberRelationshipService.cs
- UIElement.cs
- DataRowExtensions.cs
- PersonalizableTypeEntry.cs
- WindowsToolbar.cs
- EventKeyword.cs
- InputProcessorProfilesLoader.cs
- WebUtil.cs
- XmlAttributeCollection.cs
- UnsafeNetInfoNativeMethods.cs
- SortFieldComparer.cs
- DesignerAdapterAttribute.cs
- CollectionEditVerbManager.cs
- Compiler.cs
- SystemEvents.cs
- InternalEnumValidatorAttribute.cs
- TraceContextEventArgs.cs
- CaseKeyBox.xaml.cs
- StorageEndPropertyMapping.cs
- OptimizedTemplateContentHelper.cs
- PointCollection.cs
- ConnectionPoolManager.cs
- WCFModelStrings.Designer.cs
- XmlILCommand.cs