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
- BuildResult.cs
- DataPagerField.cs
- TreeNodeStyle.cs
- CodeBlockBuilder.cs
- StylusButton.cs
- TreeViewItemAutomationPeer.cs
- ParserHooks.cs
- SemanticAnalyzer.cs
- CollectionExtensions.cs
- WrappedIUnknown.cs
- WebScriptClientGenerator.cs
- MD5CryptoServiceProvider.cs
- SynchronizationContext.cs
- hebrewshape.cs
- BinaryObjectReader.cs
- DataBoundControl.cs
- DictionaryEntry.cs
- AsyncCompletedEventArgs.cs
- DataRelation.cs
- SplitterPanel.cs
- MsmqInputChannelListener.cs
- CodeDirectoryCompiler.cs
- StackSpiller.Generated.cs
- KeyValueInternalCollection.cs
- AppearanceEditorPart.cs
- QilInvokeEarlyBound.cs
- EntityViewGenerator.cs
- ThicknessAnimationBase.cs
- XmlDeclaration.cs
- GridViewColumnCollection.cs
- TransformCollection.cs
- DataGridParentRows.cs
- ErrorHandlerModule.cs
- PopupRoot.cs
- Assert.cs
- Solver.cs
- XmlSchemaAll.cs
- CompletionBookmark.cs
- DispatcherFrame.cs
- SafeHandle.cs
- OrCondition.cs
- DesignerDataParameter.cs
- TextServicesPropertyRanges.cs
- QuadraticBezierSegment.cs
- DataGridViewCellValueEventArgs.cs
- FilterableAttribute.cs
- FileLevelControlBuilderAttribute.cs
- DataSourceCacheDurationConverter.cs
- RoutedEvent.cs
- ImageAutomationPeer.cs
- ZipFileInfo.cs
- SystemWebExtensionsSectionGroup.cs
- HttpContext.cs
- URLAttribute.cs
- MoveSizeWinEventHandler.cs
- FontWeightConverter.cs
- InternalMappingException.cs
- MachineKeySection.cs
- HostingPreferredMapPath.cs
- IPPacketInformation.cs
- QuadraticBezierSegment.cs
- PeerApplication.cs
- ReachSerializerAsync.cs
- CodeGeneratorOptions.cs
- BaseTypeViewSchema.cs
- SlotInfo.cs
- HtmlMeta.cs
- GlyphElement.cs
- EditorPartChrome.cs
- DataGridViewEditingControlShowingEventArgs.cs
- ChooseAction.cs
- ParameterBuilder.cs
- BitmapCodecInfo.cs
- WindowsListBox.cs
- IsolatedStorageFilePermission.cs
- XmlWrappingReader.cs
- AddInEnvironment.cs
- InputProviderSite.cs
- UnmanagedBitmapWrapper.cs
- CounterSetInstance.cs
- RequestCacheManager.cs
- ActivityExecutionFilter.cs
- OneWayChannelListener.cs
- GPRECT.cs
- ToolStripLocationCancelEventArgs.cs
- XmlTextReaderImpl.cs
- SpellerError.cs
- PointValueSerializer.cs
- PersonalizationProviderHelper.cs
- ScriptResourceInfo.cs
- InheritanceRules.cs
- ObjectCloneHelper.cs
- safelinkcollection.cs
- Suspend.cs
- LineInfo.cs
- TokenBasedSetEnumerator.cs
- AnnotationHighlightLayer.cs
- control.ime.cs
- ListChangedEventArgs.cs
- RegexFCD.cs