Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- PageStatePersister.cs
- BitmapEffectInputData.cs
- AppDomainManager.cs
- StringFreezingAttribute.cs
- CommandHelper.cs
- smtppermission.cs
- ReadOnlyHierarchicalDataSource.cs
- MergablePropertyAttribute.cs
- ServiceProviders.cs
- CacheModeValueSerializer.cs
- InputBindingCollection.cs
- _Win32.cs
- XmlValidatingReaderImpl.cs
- ClientBuildManagerCallback.cs
- SizeKeyFrameCollection.cs
- ServiceChannelFactory.cs
- ToolboxComponentsCreatingEventArgs.cs
- Win32.cs
- PagerSettings.cs
- TextServicesCompartmentContext.cs
- RestClientProxyHandler.cs
- DataComponentNameHandler.cs
- TransformerInfo.cs
- RequestValidator.cs
- _RequestCacheProtocol.cs
- WindowsSecurityToken.cs
- HtmlTableRowCollection.cs
- ActivityTypeCodeDomSerializer.cs
- XamlReader.cs
- DataGridItemCollection.cs
- UIElementAutomationPeer.cs
- BaseCollection.cs
- CompModSwitches.cs
- EpmContentDeSerializer.cs
- CorrelationTokenTypeConvertor.cs
- BypassElement.cs
- ApplicationInfo.cs
- WindowsProgressbar.cs
- CollectionType.cs
- PageCodeDomTreeGenerator.cs
- ObjectDataSource.cs
- ResourcesBuildProvider.cs
- WebControl.cs
- DataServiceProviderWrapper.cs
- _LazyAsyncResult.cs
- CustomBindingCollectionElement.cs
- dataprotectionpermission.cs
- StringToken.cs
- PolicyLevel.cs
- PermissionListSet.cs
- WebDisplayNameAttribute.cs
- ToolStripPanel.cs
- MouseDevice.cs
- SchemaMapping.cs
- SignedXml.cs
- CollectionViewGroup.cs
- PersistenceProvider.cs
- ClusterRegistryConfigurationProvider.cs
- CultureSpecificStringDictionary.cs
- SchemaMapping.cs
- OciEnlistContext.cs
- EncryptedReference.cs
- DbParameterHelper.cs
- XmlReaderDelegator.cs
- DesignerVerb.cs
- ReaderContextStackData.cs
- CheckPair.cs
- X509UI.cs
- ConfigsHelper.cs
- PerfService.cs
- ClientSideProviderDescription.cs
- XmlMapping.cs
- RequestCacheManager.cs
- mediaclock.cs
- Preprocessor.cs
- ResourceSet.cs
- DbConnectionClosed.cs
- EndpointConfigContainer.cs
- WebPartActionVerb.cs
- InternalMappingException.cs
- CharEnumerator.cs
- IdnElement.cs
- SystemWebSectionGroup.cs
- ProgressBarHighlightConverter.cs
- ObjectDataSourceSelectingEventArgs.cs
- ModelChangedEventArgsImpl.cs
- DbConnectionPoolGroup.cs
- SelectedDatesCollection.cs
- EndpointDesigner.cs
- FlowLayout.cs
- StateChangeEvent.cs
- CodeNamespaceImport.cs
- SafeMILHandle.cs
- TrustExchangeException.cs
- ListMarkerSourceInfo.cs
- TransformedBitmap.cs
- ChildDocumentBlock.cs
- SessionStateSection.cs
- CodeArrayCreateExpression.cs
- MarkupCompilePass1.cs