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
- SByte.cs
- SpecularMaterial.cs
- Converter.cs
- QueryResponse.cs
- AppliedDeviceFiltersDialog.cs
- Scripts.cs
- MessageQueueAccessControlEntry.cs
- _AutoWebProxyScriptHelper.cs
- ProxyDataContractResolver.cs
- XmlDomTextWriter.cs
- HandledEventArgs.cs
- Filter.cs
- SecurityTokenException.cs
- FlowNode.cs
- TransportSecurityProtocol.cs
- HtmlTable.cs
- UrlPath.cs
- WaitHandle.cs
- ToolStripSeparatorRenderEventArgs.cs
- Canvas.cs
- CollectionType.cs
- RedirectionProxy.cs
- Aes.cs
- DocComment.cs
- RangeBase.cs
- SecurityPolicySection.cs
- Sql8ConformanceChecker.cs
- CodeBlockBuilder.cs
- LogSwitch.cs
- XmlBaseReader.cs
- CLRBindingWorker.cs
- TreeNodeSelectionProcessor.cs
- ColorConvertedBitmap.cs
- TextEmbeddedObject.cs
- DataChangedEventManager.cs
- SQLDecimalStorage.cs
- UnionCodeGroup.cs
- DesignerVerbCollection.cs
- ImageMapEventArgs.cs
- HtmlWindowCollection.cs
- SerializationObjectManager.cs
- WinFormsSpinner.cs
- XmlNamespaceDeclarationsAttribute.cs
- RelatedView.cs
- ConfigurationPropertyCollection.cs
- ManifestResourceInfo.cs
- XPathSelectionIterator.cs
- DataGridViewCellStyleContentChangedEventArgs.cs
- EllipseGeometry.cs
- KeySpline.cs
- TextServicesContext.cs
- CodeSnippetExpression.cs
- COM2PropertyPageUITypeConverter.cs
- WeakKeyDictionary.cs
- AddInAttribute.cs
- TextContainerChangedEventArgs.cs
- ServiceNameCollection.cs
- ListSortDescription.cs
- X509ChainElement.cs
- ClientScriptManagerWrapper.cs
- EnglishPluralizationService.cs
- AddDataControlFieldDialog.cs
- PngBitmapEncoder.cs
- SqlClientWrapperSmiStream.cs
- DataColumn.cs
- DependencyPropertyAttribute.cs
- SvcFileManager.cs
- LoadedOrUnloadedOperation.cs
- BinaryConverter.cs
- IsolatedStorageFilePermission.cs
- XomlCompilerParameters.cs
- TreeNodeCollection.cs
- InteropEnvironment.cs
- SchemaElementLookUpTableEnumerator.cs
- XmlException.cs
- EdmProviderManifest.cs
- HtmlShim.cs
- MailDefinition.cs
- TiffBitmapDecoder.cs
- BeginEvent.cs
- ContentDefinition.cs
- BindingCollection.cs
- XmlResolver.cs
- MarkupProperty.cs
- FormConverter.cs
- DesignerActionPanel.cs
- AttributeAction.cs
- TransformerConfigurationWizardBase.cs
- StateMachineSubscription.cs
- HttpModulesSection.cs
- DataGridViewCellFormattingEventArgs.cs
- GridViewSortEventArgs.cs
- CompilerTypeWithParams.cs
- WpfKnownMember.cs
- EmptyCollection.cs
- MultiView.cs
- WpfPayload.cs
- Int64AnimationBase.cs
- XmlAttribute.cs
- XPathNodeIterator.cs