Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- FileChangesMonitor.cs
- ValueTypeFixupInfo.cs
- TypeListConverter.cs
- ContextMenuService.cs
- MessageFilter.cs
- DbException.cs
- HtmlInputFile.cs
- ChtmlTextWriter.cs
- WindowManager.cs
- DbMetaDataCollectionNames.cs
- CodeExporter.cs
- SQLDateTime.cs
- AutomationTextAttribute.cs
- ProgressBarAutomationPeer.cs
- METAHEADER.cs
- Span.cs
- ApplyTemplatesAction.cs
- SspiNegotiationTokenAuthenticatorState.cs
- PersonalizationStateQuery.cs
- AssemblyInfo.cs
- RijndaelCryptoServiceProvider.cs
- StrokeCollection.cs
- XmlCompatibilityReader.cs
- InboundActivityHelper.cs
- DataGridViewLinkCell.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- ConsumerConnectionPoint.cs
- DependencyPropertyKey.cs
- ClickablePoint.cs
- TypeGeneratedEventArgs.cs
- TraceHandler.cs
- ConnectionPointConverter.cs
- MessageLoggingElement.cs
- BlurEffect.cs
- IndependentAnimationStorage.cs
- DoubleAnimationBase.cs
- SplitterDesigner.cs
- PasswordTextContainer.cs
- InlineObject.cs
- TreeViewHitTestInfo.cs
- EntityConnection.cs
- TextTreeDeleteContentUndoUnit.cs
- Socket.cs
- RegexCompilationInfo.cs
- SortQuery.cs
- Keywords.cs
- PipelineModuleStepContainer.cs
- ToolboxControl.cs
- DoubleLinkList.cs
- QilNode.cs
- SessionEndingCancelEventArgs.cs
- IPGlobalProperties.cs
- Int32Converter.cs
- ComponentConverter.cs
- RankException.cs
- Range.cs
- RuntimeVariablesExpression.cs
- ApplicationCommands.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- FontStretches.cs
- AlphaSortedEnumConverter.cs
- HandlerFactoryCache.cs
- MouseEventArgs.cs
- PrintController.cs
- ObjectDataSourceView.cs
- Evaluator.cs
- X509Certificate.cs
- EntityDataSourceEntityTypeFilterItem.cs
- OpenCollectionAsyncResult.cs
- ConstrainedDataObject.cs
- TextEditorParagraphs.cs
- MachineKeyConverter.cs
- FormatConvertedBitmap.cs
- TransformProviderWrapper.cs
- OraclePermissionAttribute.cs
- XmlElementAttribute.cs
- ObfuscationAttribute.cs
- DataGridHelper.cs
- Adorner.cs
- _AcceptOverlappedAsyncResult.cs
- SystemUnicastIPAddressInformation.cs
- RandomNumberGenerator.cs
- StyleSheetComponentEditor.cs
- MultiTrigger.cs
- SizeAnimationClockResource.cs
- DocumentCollection.cs
- AuthenticationConfig.cs
- URLString.cs
- PageThemeCodeDomTreeGenerator.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- OpCellTreeNode.cs
- CodeParameterDeclarationExpression.cs
- InputLangChangeRequestEvent.cs
- ResourceManagerWrapper.cs
- TextRunCache.cs
- ExpressionBuilder.cs
- MailBnfHelper.cs
- XAMLParseException.cs
- ZoneButton.cs
- DbConnectionPoolCounters.cs