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
- Content.cs
- CategoryAttribute.cs
- InkCanvasSelection.cs
- RawStylusInputCustomData.cs
- HostSecurityManager.cs
- PingOptions.cs
- CryptoConfig.cs
- PhysicalFontFamily.cs
- UpdateTracker.cs
- EdmType.cs
- Serializer.cs
- ImageDrawing.cs
- SoapSchemaImporter.cs
- DataList.cs
- ReplyChannelAcceptor.cs
- TypeUsage.cs
- CatalogZone.cs
- DataTableClearEvent.cs
- CriticalExceptions.cs
- ConfigurationPropertyAttribute.cs
- DataGridTextColumn.cs
- NativeWindow.cs
- SignatureResourcePool.cs
- ArrayConverter.cs
- XmlSerializerFactory.cs
- MDIControlStrip.cs
- OleDbFactory.cs
- SmtpTransport.cs
- HwndSourceParameters.cs
- Codec.cs
- IteratorDescriptor.cs
- SoapSchemaImporter.cs
- ButtonField.cs
- SecurityState.cs
- DocumentPageView.cs
- EmptyEnumerator.cs
- ZipFileInfo.cs
- _MultipleConnectAsync.cs
- ColorContextHelper.cs
- DbProviderConfigurationHandler.cs
- ApplicationContext.cs
- FolderBrowserDialog.cs
- TimeZoneInfo.cs
- _WebProxyDataBuilder.cs
- IsolatedStorage.cs
- OdbcEnvironmentHandle.cs
- WSFederationHttpSecurity.cs
- GenericEnumConverter.cs
- SocketException.cs
- WindowsAltTab.cs
- XmlSchemaSimpleTypeList.cs
- LinqDataSource.cs
- ObjectListDataBindEventArgs.cs
- DataSetSchema.cs
- Restrictions.cs
- HtmlInputSubmit.cs
- IntSecurity.cs
- EmptyCollection.cs
- FileDialogPermission.cs
- RefExpr.cs
- BypassElementCollection.cs
- SymbolDocumentInfo.cs
- DisposableCollectionWrapper.cs
- IntSecurity.cs
- ParentUndoUnit.cs
- WindowsTokenRoleProvider.cs
- RootBrowserWindowProxy.cs
- DataStreams.cs
- Triangle.cs
- Symbol.cs
- MessageQueueKey.cs
- SkipQueryOptionExpression.cs
- WorkflowTimerService.cs
- MarshalDirectiveException.cs
- BuildManager.cs
- RelOps.cs
- TriggerActionCollection.cs
- FieldNameLookup.cs
- QueryOutputWriterV1.cs
- TextBox.cs
- MemberRelationshipService.cs
- FacetDescription.cs
- WebPartTracker.cs
- TdsParserSessionPool.cs
- GridViewColumnCollection.cs
- SqlRowUpdatedEvent.cs
- EndpointAddress10.cs
- WorkflowIdleBehavior.cs
- Tuple.cs
- ToolBar.cs
- ClosureBinding.cs
- ErrorStyle.cs
- RegexCompiler.cs
- DropDownButton.cs
- GCHandleCookieTable.cs
- MenuAdapter.cs
- DataGridViewAccessibleObject.cs
- WriteFileContext.cs
- Subset.cs
- MethodBuilderInstantiation.cs