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
- SmiSettersStream.cs
- HtmlImage.cs
- MsmqInputSessionChannel.cs
- DataGridColumnReorderingEventArgs.cs
- EpmSyndicationContentSerializer.cs
- WorkflowDispatchContext.cs
- ScriptDescriptor.cs
- configsystem.cs
- CellParagraph.cs
- XmlUtf8RawTextWriter.cs
- DocumentReferenceCollection.cs
- MessageQueueException.cs
- MachineKeyConverter.cs
- FacetValueContainer.cs
- WeakReference.cs
- EventEntry.cs
- ProvidePropertyAttribute.cs
- VirtualPathUtility.cs
- EntityConnection.cs
- QueryHandler.cs
- FixedTextSelectionProcessor.cs
- EntitySqlQueryCacheEntry.cs
- _Connection.cs
- InvalidCardException.cs
- SQLDecimal.cs
- FontStretches.cs
- OperationInfoBase.cs
- SecurityPolicySection.cs
- HtmlControlPersistable.cs
- ReadOnlyDictionary.cs
- ModuleConfigurationInfo.cs
- DispatcherTimer.cs
- FindCriteriaElement.cs
- OutputCacheModule.cs
- Content.cs
- WinInetCache.cs
- ClientConfigPaths.cs
- TableRowCollection.cs
- ConfigurationElementProperty.cs
- Function.cs
- SocketAddress.cs
- LogLogRecordEnumerator.cs
- MetroSerializationManager.cs
- UnmanagedMemoryStreamWrapper.cs
- SafeMILHandle.cs
- LoginStatusDesigner.cs
- NamedPermissionSet.cs
- RegexGroup.cs
- Message.cs
- CellParaClient.cs
- BypassElement.cs
- ClassValidator.cs
- XsltLibrary.cs
- TreeBuilderXamlTranslator.cs
- ProfileEventArgs.cs
- VoiceInfo.cs
- HttpRawResponse.cs
- SelfIssuedAuthRSAPKCS1SignatureFormatter.cs
- BitmapFrameEncode.cs
- SrgsItemList.cs
- AspCompat.cs
- DSASignatureDeformatter.cs
- DeferrableContentConverter.cs
- InputScope.cs
- ToolStripComboBox.cs
- DataError.cs
- ByteKeyFrameCollection.cs
- CatalogZoneBase.cs
- Utils.cs
- AssemblyCache.cs
- PathTooLongException.cs
- SelectionRange.cs
- ValidationHelper.cs
- SemanticValue.cs
- EmbeddedMailObjectsCollection.cs
- DLinqTableProvider.cs
- ObjectStorage.cs
- HandlerBase.cs
- HandlerWithFactory.cs
- SystemParameters.cs
- TextTreeRootTextBlock.cs
- MediaTimeline.cs
- DatatypeImplementation.cs
- SqlDataSourceParameterParser.cs
- DoWhile.cs
- _NativeSSPI.cs
- ActiveXHost.cs
- DrawingImage.cs
- NonParentingControl.cs
- HtmlInputRadioButton.cs
- StructuredType.cs
- QualificationDataAttribute.cs
- FontResourceCache.cs
- RoleService.cs
- Propagator.JoinPropagator.JoinPredicateVisitor.cs
- Timer.cs
- FloaterParagraph.cs
- ProcessHostMapPath.cs
- AddDataControlFieldDialog.cs
- QualifiedCellIdBoolean.cs