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
- DetailsViewDeletedEventArgs.cs
- NonParentingControl.cs
- DependencyPropertyKind.cs
- DesignerPainter.cs
- TextTreeTextElementNode.cs
- ToolTipAutomationPeer.cs
- DataControlImageButton.cs
- XhtmlTextWriter.cs
- KeyValueInternalCollection.cs
- IApplicationTrustManager.cs
- RemoteWebConfigurationHostServer.cs
- PageSettings.cs
- CustomAttributeBuilder.cs
- CaseCqlBlock.cs
- SystemIPGlobalStatistics.cs
- HttpGetClientProtocol.cs
- FreezableOperations.cs
- SqlMetaData.cs
- ExtendedPropertiesHandler.cs
- GroupStyle.cs
- securestring.cs
- FrameAutomationPeer.cs
- XmlAttributeAttribute.cs
- Point.cs
- RuntimeHandles.cs
- PrimaryKeyTypeConverter.cs
- LinkClickEvent.cs
- ConstructorNeedsTagAttribute.cs
- MediaTimeline.cs
- XpsFixedPageReaderWriter.cs
- MethodAccessException.cs
- CallbackBehaviorAttribute.cs
- DataGridTextBoxColumn.cs
- EventDescriptorCollection.cs
- PathSegmentCollection.cs
- DataRelationCollection.cs
- KnownBoxes.cs
- sortedlist.cs
- ActiveXContainer.cs
- StorageAssociationSetMapping.cs
- WebServiceParameterData.cs
- EntityClientCacheEntry.cs
- AbsoluteQuery.cs
- ImageField.cs
- CreatingCookieEventArgs.cs
- ModelItemKeyValuePair.cs
- HandlerWithFactory.cs
- UshortList2.cs
- ProfilePropertyNameValidator.cs
- BuildProvider.cs
- DiscoveryMessageSequenceGenerator.cs
- JapaneseCalendar.cs
- SqlNotificationRequest.cs
- ToolboxBitmapAttribute.cs
- AddInSegmentDirectoryNotFoundException.cs
- CallbackValidator.cs
- NativeMethods.cs
- DataGridLengthConverter.cs
- SmtpNtlmAuthenticationModule.cs
- FormDesigner.cs
- Base64Stream.cs
- StandardTransformFactory.cs
- ModelPropertyCollectionImpl.cs
- DataAdapter.cs
- AVElementHelper.cs
- HtmlInputReset.cs
- SchemaCollectionCompiler.cs
- HostingEnvironmentSection.cs
- SafeRightsManagementQueryHandle.cs
- BindingElementExtensionElement.cs
- NameNode.cs
- InputScopeAttribute.cs
- DefaultProxySection.cs
- TypeCodeDomSerializer.cs
- LogicalExpressionEditor.cs
- HttpAsyncResult.cs
- DataServices.cs
- ProfileSettings.cs
- IdentityValidationException.cs
- AndAlso.cs
- AssertUtility.cs
- Brushes.cs
- Console.cs
- TextEffectResolver.cs
- MimeTypeAttribute.cs
- RequestQueryParser.cs
- ChtmlTextWriter.cs
- ZoneMembershipCondition.cs
- KeyPullup.cs
- RangeValuePatternIdentifiers.cs
- HitTestWithGeometryDrawingContextWalker.cs
- NetworkInterface.cs
- AnonymousIdentificationSection.cs
- XamlReader.cs
- UniqueID.cs
- EndEvent.cs
- ConfigurationSectionHelper.cs
- ImageSourceValueSerializer.cs
- UInt16Converter.cs
- QueryPageSettingsEventArgs.cs