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
- MultiViewDesigner.cs
- SimpleApplicationHost.cs
- JoinElimination.cs
- ApplicationSecurityInfo.cs
- SoapTypeAttribute.cs
- ArgumentException.cs
- DependentList.cs
- ReceiveSecurityHeaderEntry.cs
- ReadOnlyTernaryTree.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- RTLAwareMessageBox.cs
- Focus.cs
- Point3DAnimationBase.cs
- FixedSOMPageElement.cs
- TraceInternal.cs
- ICspAsymmetricAlgorithm.cs
- ConnectionPoolManager.cs
- Panel.cs
- FrameworkTextComposition.cs
- XmlNamespaceManager.cs
- RequestQueryParser.cs
- DataStorage.cs
- regiisutil.cs
- BitmapEffectGroup.cs
- Errors.cs
- GestureRecognitionResult.cs
- Int16AnimationBase.cs
- HandledMouseEvent.cs
- PassportAuthenticationEventArgs.cs
- Roles.cs
- ReadOnlyObservableCollection.cs
- UnsafeNativeMethods.cs
- HttpCookieCollection.cs
- DataPagerFieldCollection.cs
- EventLogPermission.cs
- ImportCatalogPart.cs
- CryptoApi.cs
- DiscriminatorMap.cs
- PersonalizationProviderCollection.cs
- XmlSerializerFactory.cs
- StackSpiller.Temps.cs
- TableItemPatternIdentifiers.cs
- PropertyGroupDescription.cs
- DescendantQuery.cs
- IntermediatePolicyValidator.cs
- PtsHelper.cs
- TemplatePropertyEntry.cs
- PrinterResolution.cs
- ExcCanonicalXml.cs
- HttpValueCollection.cs
- Section.cs
- XmlSchemaRedefine.cs
- brushes.cs
- TextTabProperties.cs
- MetadataArtifactLoaderCompositeFile.cs
- CheckBox.cs
- SQLUtility.cs
- OrderByBuilder.cs
- NonSerializedAttribute.cs
- ConfigurationValue.cs
- OdbcEnvironment.cs
- FixedHighlight.cs
- WorkflowItemsPresenter.cs
- SoapIgnoreAttribute.cs
- DataControlButton.cs
- FilteredXmlReader.cs
- SyntaxCheck.cs
- PagesChangedEventArgs.cs
- OdbcInfoMessageEvent.cs
- DCSafeHandle.cs
- ElementFactory.cs
- PathFigure.cs
- QueueProcessor.cs
- TimeZone.cs
- HijriCalendar.cs
- DBParameter.cs
- Geometry.cs
- HtmlShimManager.cs
- LineServices.cs
- XmlImplementation.cs
- ElementAtQueryOperator.cs
- DataServiceStreamProviderWrapper.cs
- VectorAnimation.cs
- AddInDeploymentState.cs
- TextClipboardData.cs
- TrustLevel.cs
- MarkerProperties.cs
- IndexedSelectQueryOperator.cs
- Figure.cs
- ReadContentAsBinaryHelper.cs
- ServiceParser.cs
- MailWebEventProvider.cs
- UTF8Encoding.cs
- UnsafeNativeMethodsTablet.cs
- HttpPostedFile.cs
- DelegatingConfigHost.cs
- ReadOnlyDictionary.cs
- Function.cs
- TimeoutException.cs
- NullableDecimalSumAggregationOperator.cs