Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- _HTTPDateParse.cs
- EventProviderWriter.cs
- WorkflowTransactionOptions.cs
- TrackingAnnotationCollection.cs
- ZoneIdentityPermission.cs
- SingleSelectRootGridEntry.cs
- WebServicesInteroperability.cs
- AppSettingsReader.cs
- Registry.cs
- ScriptingSectionGroup.cs
- GAC.cs
- XmlSchemaImporter.cs
- WindowsGraphicsWrapper.cs
- MetadataHelper.cs
- DiagnosticTraceSchemas.cs
- TreeView.cs
- ExeConfigurationFileMap.cs
- AssemblyBuilder.cs
- OutOfMemoryException.cs
- WebEventTraceProvider.cs
- WindowsFormsLinkLabel.cs
- StylusDownEventArgs.cs
- EditorZone.cs
- SelectedGridItemChangedEvent.cs
- SqlClientMetaDataCollectionNames.cs
- SafeNativeMethods.cs
- TextRange.cs
- PenCursorManager.cs
- SQLBinaryStorage.cs
- IntegerValidator.cs
- TokenizerHelper.cs
- ReservationCollection.cs
- Dump.cs
- ResizeGrip.cs
- base64Transforms.cs
- PersonalizationDictionary.cs
- SqlCacheDependencyDatabaseCollection.cs
- FloaterParagraph.cs
- AddingNewEventArgs.cs
- CultureInfoConverter.cs
- FamilyMap.cs
- ImagingCache.cs
- basevalidator.cs
- TreeBuilderBamlTranslator.cs
- followingquery.cs
- MulticastIPAddressInformationCollection.cs
- PageSettings.cs
- ImageSourceConverter.cs
- PointUtil.cs
- _OverlappedAsyncResult.cs
- GeneralTransformCollection.cs
- ReverseInheritProperty.cs
- ThreadNeutralSemaphore.cs
- SystemColors.cs
- BrowserCapabilitiesCompiler.cs
- LayoutEditorPart.cs
- ReaderContextStackData.cs
- CornerRadiusConverter.cs
- FullTextState.cs
- TextParagraphCache.cs
- RootBuilder.cs
- X509Chain.cs
- LoginView.cs
- X509CertificateCollection.cs
- MexTcpBindingCollectionElement.cs
- Byte.cs
- RtType.cs
- BaseTemplateCodeDomTreeGenerator.cs
- StylusEventArgs.cs
- SourceElementsCollection.cs
- Timer.cs
- LinqDataSourceStatusEventArgs.cs
- NativeMethods.cs
- ProfileSettingsCollection.cs
- Padding.cs
- ImmutableCommunicationTimeouts.cs
- InstanceCompleteException.cs
- DispatcherExceptionFilterEventArgs.cs
- XmlDataLoader.cs
- InterleavedZipPartStream.cs
- ProfileBuildProvider.cs
- RegisteredArrayDeclaration.cs
- ToolStripComboBox.cs
- UIElementIsland.cs
- DataGridViewColumnHeaderCell.cs
- WhitespaceRuleLookup.cs
- ListControlBoundActionList.cs
- ObfuscateAssemblyAttribute.cs
- Utilities.cs
- TraceXPathNavigator.cs
- BooleanAnimationUsingKeyFrames.cs
- TagNameToTypeMapper.cs
- latinshape.cs
- SystemIcmpV6Statistics.cs
- PackagingUtilities.cs
- StreamAsIStream.cs
- Fx.cs
- WebColorConverter.cs
- RotateTransform.cs
- ServiceOperation.cs