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
- RuntimeConfig.cs
- ChainOfResponsibility.cs
- WebPartConnectionsDisconnectVerb.cs
- CacheVirtualItemsEvent.cs
- XmlLangPropertyAttribute.cs
- BreakRecordTable.cs
- SafeTokenHandle.cs
- ChildrenQuery.cs
- SqlMetaData.cs
- Duration.cs
- InfoCardUIAgent.cs
- TextTrailingCharacterEllipsis.cs
- XmlNamespaceManager.cs
- ColumnMapProcessor.cs
- WebScriptServiceHostFactory.cs
- XPathNavigatorKeyComparer.cs
- BitmapEffectGroup.cs
- BasicViewGenerator.cs
- XhtmlBasicPageAdapter.cs
- ClientRoleProvider.cs
- SystemInformation.cs
- CannotUnloadAppDomainException.cs
- XmlWriter.cs
- PreviewPageInfo.cs
- NullableFloatSumAggregationOperator.cs
- PlatformNotSupportedException.cs
- RegistryKey.cs
- SchemaEntity.cs
- EtwTrace.cs
- ProcessHostServerConfig.cs
- HyperLinkDesigner.cs
- TargetParameterCountException.cs
- EntityDataSourceChangingEventArgs.cs
- SignatureResourcePool.cs
- LookupNode.cs
- CustomWebEventKey.cs
- OutgoingWebRequestContext.cs
- DrawingContextDrawingContextWalker.cs
- OdbcPermission.cs
- SqlServer2KCompatibilityAnnotation.cs
- ReverseComparer.cs
- MutexSecurity.cs
- SqlConnectionHelper.cs
- KeyTimeConverter.cs
- KeyPressEvent.cs
- RectangleGeometry.cs
- PipeSecurity.cs
- ContextMenu.cs
- WebBrowserBase.cs
- EntityModelSchemaGenerator.cs
- WorkflowWebService.cs
- DoubleLinkList.cs
- Exceptions.cs
- CompletionCallbackWrapper.cs
- DrawingCollection.cs
- OrderByQueryOptionExpression.cs
- LocalizedNameDescriptionPair.cs
- TrackingConditionCollection.cs
- GlyphTypeface.cs
- SimpleHandlerFactory.cs
- ProcessHostFactoryHelper.cs
- ReadOnlyPermissionSet.cs
- HotSpotCollection.cs
- TextFormatterHost.cs
- Message.cs
- DoubleLinkList.cs
- RankException.cs
- CodeSnippetStatement.cs
- SystemResourceHost.cs
- DataGridColumnEventArgs.cs
- XPathSelectionIterator.cs
- HtmlMeta.cs
- XmlSchemaChoice.cs
- ImmutableCollection.cs
- PeerNameRegistration.cs
- PkcsMisc.cs
- WebServiceHandler.cs
- HttpResponseInternalBase.cs
- BatchServiceHost.cs
- ConstraintConverter.cs
- ConfigXmlText.cs
- XmlMembersMapping.cs
- GraphicsState.cs
- SqlOuterApplyReducer.cs
- ACL.cs
- WebPartManager.cs
- SweepDirectionValidation.cs
- HelpInfo.cs
- WindowsStartMenu.cs
- CodeMethodReturnStatement.cs
- MergeLocalizationDirectives.cs
- BaseParser.cs
- HotSpotCollection.cs
- UnionCodeGroup.cs
- ConnectionPoolManager.cs
- unsafenativemethodstextservices.cs
- NumberFormatter.cs
- ExpressionEditorAttribute.cs
- LoginViewDesigner.cs
- ReferentialConstraint.cs