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
- FileDialog.cs
- Effect.cs
- StatusBarPanelClickEvent.cs
- Matrix3D.cs
- HwndKeyboardInputProvider.cs
- EncoderExceptionFallback.cs
- PostBackTrigger.cs
- SmtpDigestAuthenticationModule.cs
- TreeNodeClickEventArgs.cs
- ProtocolImporter.cs
- AlternationConverter.cs
- TreeNode.cs
- ProxySimple.cs
- SubtreeProcessor.cs
- InternalTypeHelper.cs
- EventLogEntryCollection.cs
- ObjectNavigationPropertyMapping.cs
- TreeViewAutomationPeer.cs
- ConstraintCollection.cs
- sqlpipe.cs
- future.cs
- XmlAttributeProperties.cs
- XamlStyleSerializer.cs
- ClientRolePrincipal.cs
- _FtpDataStream.cs
- DataIdProcessor.cs
- InvokeSchedule.cs
- ColorContextHelper.cs
- ImageInfo.cs
- DriveInfo.cs
- LocationUpdates.cs
- SqlProfileProvider.cs
- MarkedHighlightComponent.cs
- StructuredTypeEmitter.cs
- OdbcDataReader.cs
- InternalConfigRoot.cs
- Geometry3D.cs
- precedingsibling.cs
- ObjectSet.cs
- InkCanvasSelection.cs
- XmlChoiceIdentifierAttribute.cs
- ReferencedAssembly.cs
- QuotedPrintableStream.cs
- QEncodedStream.cs
- EntitySqlQueryCacheKey.cs
- PropertyBuilder.cs
- MetadataItem_Static.cs
- QuotedStringWriteStateInfo.cs
- CaseInsensitiveHashCodeProvider.cs
- ServiceReference.cs
- FieldAccessException.cs
- SchemaMapping.cs
- RealizationContext.cs
- HwndSourceKeyboardInputSite.cs
- CreateUserWizardStep.cs
- FormViewInsertedEventArgs.cs
- WebPartTransformerCollection.cs
- AvTraceDetails.cs
- WeakReference.cs
- FontFamilyConverter.cs
- MarkupExtensionReturnTypeAttribute.cs
- XamlClipboardData.cs
- SlipBehavior.cs
- CachingHintValidation.cs
- ExpressionPrefixAttribute.cs
- ByteAnimationUsingKeyFrames.cs
- CodePrimitiveExpression.cs
- DataServiceEntityAttribute.cs
- RowUpdatedEventArgs.cs
- ReaderWriterLock.cs
- SequentialUshortCollection.cs
- ConstraintCollection.cs
- SecureConversationServiceCredential.cs
- LocalizeDesigner.cs
- clipboard.cs
- PathSegmentCollection.cs
- ViewRendering.cs
- DataRowCollection.cs
- InvalidChannelBindingException.cs
- DataGridViewSelectedCellCollection.cs
- PropertyIDSet.cs
- RecognizerStateChangedEventArgs.cs
- AnimationException.cs
- TextEffect.cs
- WebBrowserEvent.cs
- UrlParameterWriter.cs
- EmissiveMaterial.cs
- SqlFacetAttribute.cs
- TextBounds.cs
- WorkflowInstanceSuspendedRecord.cs
- _HTTPDateParse.cs
- CqlLexer.cs
- PageBuildProvider.cs
- PropertyEntry.cs
- ServiceModelSectionGroup.cs
- RadioButtonPopupAdapter.cs
- _SslStream.cs
- PolicyManager.cs
- CodeParameterDeclarationExpressionCollection.cs
- SharedPersonalizationStateInfo.cs