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
- Assembly.cs
- ScrollBar.cs
- WebControlsSection.cs
- XamlBuildTaskServices.cs
- FileSecurity.cs
- BaseResourcesBuildProvider.cs
- RotateTransform.cs
- SystemWebSectionGroup.cs
- ContextInformation.cs
- CodeTypeReferenceSerializer.cs
- ApplicationCommands.cs
- ICspAsymmetricAlgorithm.cs
- ExpressionConverter.cs
- FixedDocument.cs
- RouteItem.cs
- TemplateKeyConverter.cs
- WebPartHelpVerb.cs
- CaretElement.cs
- SslStream.cs
- DataSourceXmlAttributeAttribute.cs
- LogManagementAsyncResult.cs
- NumericPagerField.cs
- FigureParagraph.cs
- TextAutomationPeer.cs
- _FtpDataStream.cs
- TypeConverter.cs
- ToolStripComboBox.cs
- SubqueryTrackingVisitor.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- AppLevelCompilationSectionCache.cs
- SubMenuStyle.cs
- IndexedEnumerable.cs
- XamlTreeBuilder.cs
- Vector3DIndependentAnimationStorage.cs
- ApplicationHost.cs
- GenericTypeParameterBuilder.cs
- QilReference.cs
- TTSEvent.cs
- LabelAutomationPeer.cs
- PointCollectionConverter.cs
- IpcChannel.cs
- WizardPanel.cs
- XmlSortKey.cs
- FunctionParameter.cs
- TextTreeInsertUndoUnit.cs
- processwaithandle.cs
- InsufficientMemoryException.cs
- GridViewCancelEditEventArgs.cs
- VariableBinder.cs
- NameScopePropertyAttribute.cs
- AncillaryOps.cs
- ContractMethodInfo.cs
- ExternalException.cs
- Message.cs
- DiscoveryClientRequestChannel.cs
- EnumBuilder.cs
- XPathNodeInfoAtom.cs
- ScriptManager.cs
- _NetworkingPerfCounters.cs
- StorageInfo.cs
- CopyEncoder.cs
- RecognizedAudio.cs
- TextPointer.cs
- EntityTemplateFactory.cs
- SpecularMaterial.cs
- Dispatcher.cs
- StaticTextPointer.cs
- DbMetaDataCollectionNames.cs
- MergeLocalizationDirectives.cs
- FileIOPermission.cs
- VariantWrapper.cs
- DataTable.cs
- Crc32.cs
- RadioButtonPopupAdapter.cs
- ToggleProviderWrapper.cs
- DataException.cs
- Model3D.cs
- CompiledXpathExpr.cs
- CancellationState.cs
- ThicknessConverter.cs
- AppDomain.cs
- XmlIgnoreAttribute.cs
- PolicyImporterElement.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- DbUpdateCommandTree.cs
- CommandHelpers.cs
- RequestCachingSection.cs
- DirectionalLight.cs
- MethodCallExpression.cs
- Literal.cs
- RelatedView.cs
- EmbeddedMailObject.cs
- ClientConfigurationHost.cs
- MetadataPropertyCollection.cs
- ServicesExceptionNotHandledEventArgs.cs
- ChameleonKey.cs
- DictionaryCustomTypeDescriptor.cs
- XhtmlBasicTextViewAdapter.cs
- ProvidersHelper.cs
- ConfigurationLockCollection.cs