Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- AppSettingsExpressionBuilder.cs
- TextParagraphProperties.cs
- ParserContext.cs
- CompositeTypefaceMetrics.cs
- CacheChildrenQuery.cs
- SingleAnimationBase.cs
- EventHandlingScope.cs
- Quaternion.cs
- cookiecontainer.cs
- ObjectMaterializedEventArgs.cs
- DataGridTableStyleMappingNameEditor.cs
- InputReport.cs
- TextTreeTextElementNode.cs
- UnsafeNativeMethods.cs
- CustomErrorsSection.cs
- ContainerSelectorActiveEvent.cs
- TimeoutTimer.cs
- XmlElementAttributes.cs
- ITreeGenerator.cs
- WindowsGraphicsWrapper.cs
- DocumentSequenceHighlightLayer.cs
- PageMediaSize.cs
- WindowsScrollBar.cs
- XPathChildIterator.cs
- CustomExpression.cs
- SiteMapDataSourceDesigner.cs
- _ChunkParse.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- ToolStripRendererSwitcher.cs
- KeyConverter.cs
- SessionState.cs
- BindingExpressionUncommonField.cs
- NetworkStream.cs
- RelationshipFixer.cs
- _UriSyntax.cs
- PersistenceTypeAttribute.cs
- BamlLocalizabilityResolver.cs
- XmlEntityReference.cs
- SqlExpander.cs
- VariantWrapper.cs
- StylusPlugInCollection.cs
- RC2CryptoServiceProvider.cs
- Rijndael.cs
- ContextQuery.cs
- hwndwrapper.cs
- GatewayIPAddressInformationCollection.cs
- ImageEditor.cs
- ContractCodeDomInfo.cs
- FormatPage.cs
- TransactionTraceIdentifier.cs
- ListParagraph.cs
- Rijndael.cs
- SinglePageViewer.cs
- DrawingCollection.cs
- PolyBezierSegment.cs
- Label.cs
- SerializationSectionGroup.cs
- AsymmetricSignatureFormatter.cs
- RoleService.cs
- ClockGroup.cs
- Avt.cs
- ConvertBinder.cs
- PageThemeParser.cs
- CatchBlock.cs
- KeyTimeConverter.cs
- MethodBody.cs
- LineGeometry.cs
- HostingEnvironment.cs
- SecurityIdentifierElement.cs
- DataObjectSettingDataEventArgs.cs
- LOSFormatter.cs
- PropertySegmentSerializer.cs
- TextSearch.cs
- DateTimePicker.cs
- ProcessInputEventArgs.cs
- XmlILOptimizerVisitor.cs
- SafeRightsManagementQueryHandle.cs
- FrameworkTextComposition.cs
- COM2ColorConverter.cs
- WSFederationHttpBinding.cs
- EditingCommands.cs
- CodeMemberMethod.cs
- TreeBuilderBamlTranslator.cs
- ConfigurationStrings.cs
- SchemaImporterExtension.cs
- AlphabetConverter.cs
- WebRequestModuleElementCollection.cs
- ErrorWrapper.cs
- WindowClosedEventArgs.cs
- UnknownWrapper.cs
- assemblycache.cs
- BrowserCapabilitiesFactoryBase.cs
- HwndSourceParameters.cs
- Helpers.cs
- ObsoleteAttribute.cs
- TypeDescriptor.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- _TransmitFileOverlappedAsyncResult.cs
- Select.cs
- CodeSubDirectory.cs