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
- ObjectNotFoundException.cs
- SqlCommandSet.cs
- FixedLineResult.cs
- OracleBoolean.cs
- AnnotationMap.cs
- filewebresponse.cs
- PhysicalFontFamily.cs
- SystemIcmpV6Statistics.cs
- GlobalizationSection.cs
- GraphicsPath.cs
- OutKeywords.cs
- NonClientArea.cs
- DataServiceQueryOfT.cs
- DiagnosticsConfigurationHandler.cs
- ProcessHost.cs
- TypeExtension.cs
- EnvelopedPkcs7.cs
- RightsManagementEncryptionTransform.cs
- updateconfighost.cs
- CustomErrorsSectionWrapper.cs
- WeakReferenceEnumerator.cs
- ExpressionBuilder.cs
- XslVisitor.cs
- ConvertersCollection.cs
- AssemblyUtil.cs
- FixedPage.cs
- ButtonPopupAdapter.cs
- ScrollItemPatternIdentifiers.cs
- ExclusiveCanonicalizationTransform.cs
- SctClaimDictionary.cs
- complextypematerializer.cs
- TreeViewImageKeyConverter.cs
- Internal.cs
- ReaderWriterLockWrapper.cs
- Effect.cs
- Command.cs
- InternalTypeHelper.cs
- Qualifier.cs
- ImageIndexConverter.cs
- SectionXmlInfo.cs
- WCFBuildProvider.cs
- Util.cs
- TemplateDefinition.cs
- Canvas.cs
- PersonalizationStateQuery.cs
- DynamicEndpointElement.cs
- AppearanceEditorPart.cs
- ButtonStandardAdapter.cs
- ResourcePool.cs
- DataErrorValidationRule.cs
- TreeViewImageKeyConverter.cs
- KnownBoxes.cs
- XmlILConstructAnalyzer.cs
- UriTemplateEquivalenceComparer.cs
- FontWeight.cs
- AuthenticationManager.cs
- TransformCryptoHandle.cs
- TemplatedMailWebEventProvider.cs
- XmlElementAttribute.cs
- TitleStyle.cs
- InternalResources.cs
- TimeSpanMinutesConverter.cs
- TextPointerBase.cs
- UrlParameterReader.cs
- SoapInteropTypes.cs
- SelectionChangedEventArgs.cs
- EntityClientCacheEntry.cs
- OdbcReferenceCollection.cs
- XsltOutput.cs
- AcceleratedTokenProvider.cs
- XmlBuffer.cs
- SqlCacheDependencyDatabase.cs
- SecureStringHasher.cs
- JsonReaderWriterFactory.cs
- InlineCategoriesDocument.cs
- Helper.cs
- ColorPalette.cs
- SecurityManager.cs
- HostedHttpRequestAsyncResult.cs
- KeyPressEvent.cs
- DesignTimeValidationFeature.cs
- StateItem.cs
- DateTimeStorage.cs
- PeerObject.cs
- MimeFormatter.cs
- AsyncCompletedEventArgs.cs
- OutputCacheSection.cs
- MobileControlBuilder.cs
- DefaultBinder.cs
- CancellationToken.cs
- JoinQueryOperator.cs
- FamilyTypefaceCollection.cs
- ParameterModifier.cs
- BadImageFormatException.cs
- CTreeGenerator.cs
- ProfessionalColors.cs
- ImageButton.cs
- RegexGroup.cs
- ConnectionConsumerAttribute.cs
- SmtpClient.cs