Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- util.cs
- PageThemeParser.cs
- UIElementHelper.cs
- XmlElementCollection.cs
- GeneralTransform3DCollection.cs
- SoapEnumAttribute.cs
- SqlRowUpdatedEvent.cs
- VisualBrush.cs
- ManagementNamedValueCollection.cs
- WebPartEventArgs.cs
- CryptoProvider.cs
- Subtree.cs
- ControlUtil.cs
- XsltException.cs
- CellTreeNode.cs
- Substitution.cs
- OnOperation.cs
- InfoCardService.cs
- RepeaterCommandEventArgs.cs
- TextFormatterHost.cs
- XmlAttributeOverrides.cs
- EntityParameterCollection.cs
- AutomationAttributeInfo.cs
- WizardStepBase.cs
- ArraySortHelper.cs
- SpecialNameAttribute.cs
- XhtmlBasicObjectListAdapter.cs
- ListViewItemCollectionEditor.cs
- AnnotationResourceCollection.cs
- MasterPageBuildProvider.cs
- SocketElement.cs
- DataTableCollection.cs
- CompilerInfo.cs
- IPHostEntry.cs
- ElasticEase.cs
- SynchronousSendBindingElement.cs
- ScaleTransform.cs
- CaseInsensitiveHashCodeProvider.cs
- Vector3DValueSerializer.cs
- WindowsRegion.cs
- Translator.cs
- FileAuthorizationModule.cs
- Vector3DAnimationUsingKeyFrames.cs
- XmlTextReaderImplHelpers.cs
- OLEDB_Enum.cs
- UnaryQueryOperator.cs
- GenericAuthenticationEventArgs.cs
- SettingsBindableAttribute.cs
- AlphaSortedEnumConverter.cs
- _ContextAwareResult.cs
- ByteStorage.cs
- XPathNavigator.cs
- DataRelation.cs
- AttributeProviderAttribute.cs
- CodeTypeReferenceExpression.cs
- CellLabel.cs
- RootBrowserWindowProxy.cs
- ToolStripRendererSwitcher.cs
- CodeDelegateCreateExpression.cs
- PeerNearMe.cs
- InternalCache.cs
- FontFamilyIdentifier.cs
- CompositeControl.cs
- AnonymousIdentificationSection.cs
- RuleSettingsCollection.cs
- IArgumentProvider.cs
- ReadOnlyKeyedCollection.cs
- TableLayoutRowStyleCollection.cs
- Literal.cs
- OneOfTypeConst.cs
- HtmlTableCellCollection.cs
- StringFunctions.cs
- InterleavedZipPartStream.cs
- LoginAutoFormat.cs
- KeyedHashAlgorithm.cs
- DataStorage.cs
- CatalogPartChrome.cs
- xmlsaver.cs
- SpeakProgressEventArgs.cs
- KeyValueConfigurationCollection.cs
- SystemIPv6InterfaceProperties.cs
- SqlMethodCallConverter.cs
- CatalogZoneBase.cs
- WebColorConverter.cs
- XsdValidatingReader.cs
- SqlWebEventProvider.cs
- JsonEnumDataContract.cs
- IApplicationTrustManager.cs
- WebServiceEnumData.cs
- MimePart.cs
- StrongNameMembershipCondition.cs
- SizeAnimation.cs
- DescendentsWalker.cs
- FigureHelper.cs
- ComponentChangedEvent.cs
- KeyboardDevice.cs
- ChannelParameterCollection.cs
- DeferredSelectedIndexReference.cs
- GeneratedView.cs
- HttpRequestWrapper.cs