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
- FlowLayoutSettings.cs
- ToolStripDropDown.cs
- UnmanagedBitmapWrapper.cs
- DataViewManager.cs
- connectionpool.cs
- MediaPlayerState.cs
- EdmFunctions.cs
- ContextDataSourceView.cs
- DataColumnMappingCollection.cs
- XmlAttributeAttribute.cs
- nulltextnavigator.cs
- IisTraceListener.cs
- CallTemplateAction.cs
- PropertyKey.cs
- ConfigurationLocationCollection.cs
- GuidelineCollection.cs
- TimeZoneNotFoundException.cs
- HttpConfigurationSystem.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- SecurityDescriptor.cs
- MenuBase.cs
- FileDialogCustomPlace.cs
- GridViewCommandEventArgs.cs
- SemaphoreFullException.cs
- HierarchicalDataBoundControl.cs
- MobileResource.cs
- MessageLogger.cs
- JpegBitmapDecoder.cs
- PermissionSet.cs
- SqlVisitor.cs
- ErrorProvider.cs
- newinstructionaction.cs
- XmlElement.cs
- _IPv6Address.cs
- ListBindableAttribute.cs
- ToolStripRenderer.cs
- Color.cs
- FormsAuthenticationCredentials.cs
- FileLoadException.cs
- IItemContainerGenerator.cs
- PrimaryKeyTypeConverter.cs
- ListSourceHelper.cs
- OdbcConnectionFactory.cs
- _CacheStreams.cs
- HelpEvent.cs
- RadioButton.cs
- ErrorProvider.cs
- HttpClientCertificate.cs
- AccessibleObject.cs
- DataTemplateSelector.cs
- NumberSubstitution.cs
- LoginName.cs
- DynamicActionMessageFilter.cs
- ActivityInfo.cs
- NamedPermissionSet.cs
- HttpPostedFileWrapper.cs
- MethodBuilder.cs
- securestring.cs
- Latin1Encoding.cs
- WindowHideOrCloseTracker.cs
- WizardStepBase.cs
- Transform3D.cs
- AttributeUsageAttribute.cs
- WmpBitmapDecoder.cs
- PeoplePickerWrapper.cs
- DateTime.cs
- COM2IDispatchConverter.cs
- ComponentEvent.cs
- CachedRequestParams.cs
- ListViewInsertEventArgs.cs
- EntityDataSourceEntityTypeFilterConverter.cs
- ListViewSelectEventArgs.cs
- MailBnfHelper.cs
- XsltLibrary.cs
- ContentElementAutomationPeer.cs
- Command.cs
- XPathMessageFilterTable.cs
- TextSelectionHighlightLayer.cs
- _LoggingObject.cs
- ZoneButton.cs
- PopupEventArgs.cs
- ReflectionUtil.cs
- XmlCharType.cs
- Win32.cs
- XAMLParseException.cs
- TypeValidationEventArgs.cs
- SQLDouble.cs
- ConditionChanges.cs
- XmlLanguage.cs
- NavigationEventArgs.cs
- SafeNativeMethods.cs
- GridViewAutomationPeer.cs
- InternalTypeHelper.cs
- TimeSpanValidatorAttribute.cs
- FilterableData.cs
- TaskDesigner.cs
- SystemWebExtensionsSectionGroup.cs
- DiscoveryDocument.cs
- SelectionItemPattern.cs
- CommandField.cs