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
- HtmlSelect.cs
- SamlAssertion.cs
- SerializationInfo.cs
- EditorPartChrome.cs
- NumberAction.cs
- DynamicControlParameter.cs
- OrderedEnumerableRowCollection.cs
- HtmlTextArea.cs
- EntityCommand.cs
- WindowsAuthenticationModule.cs
- CodeLinePragma.cs
- ExpressionBuilderCollection.cs
- BinaryWriter.cs
- FormParameter.cs
- MembershipUser.cs
- ScaleTransform3D.cs
- RuntimeHelpers.cs
- SettingsPropertyCollection.cs
- StreamSecurityUpgradeInitiatorAsyncResult.cs
- ObjectToModelValueConverter.cs
- SecurityKeyIdentifier.cs
- DataError.cs
- StorageMappingItemLoader.cs
- FixUpCollection.cs
- CapabilitiesAssignment.cs
- HashSetDebugView.cs
- JavaScriptObjectDeserializer.cs
- Visual3D.cs
- Path.cs
- Path.cs
- Splitter.cs
- TextReader.cs
- BuilderPropertyEntry.cs
- DataGridState.cs
- MsmqBindingMonitor.cs
- RadioButtonAutomationPeer.cs
- ToolStripItemTextRenderEventArgs.cs
- Positioning.cs
- ExceptionUtil.cs
- CultureSpecificCharacterBufferRange.cs
- RunClient.cs
- UserNameSecurityTokenProvider.cs
- VariableQuery.cs
- HideDisabledControlAdapter.cs
- FileDialogCustomPlaces.cs
- EndpointInfoCollection.cs
- TypeToken.cs
- SqlInternalConnection.cs
- WhitespaceReader.cs
- InvokeMethodDesigner.xaml.cs
- ArgumentException.cs
- GrowingArray.cs
- Row.cs
- SortDescriptionCollection.cs
- FileUpload.cs
- TemplateComponentConnector.cs
- ServicePointManagerElement.cs
- RelationshipEndMember.cs
- ChainedAsyncResult.cs
- TransformGroup.cs
- AxisAngleRotation3D.cs
- Tool.cs
- ListBoxChrome.cs
- Config.cs
- ActivitySurrogate.cs
- XmlName.cs
- SkipStoryboardToFill.cs
- PerformanceCounterPermissionAttribute.cs
- XmlSchemaGroup.cs
- AliasedExpr.cs
- PanelDesigner.cs
- DataTable.cs
- EntityContainer.cs
- ConfigurationSectionHelper.cs
- ManagedIStream.cs
- WebEncodingValidatorAttribute.cs
- ColumnMapCopier.cs
- SqlComparer.cs
- SessionStateUtil.cs
- ToolStripContentPanel.cs
- CryptoApi.cs
- COM2ExtendedTypeConverter.cs
- TextBoxAutomationPeer.cs
- Timeline.cs
- XmlSchemaFacet.cs
- ImageField.cs
- GridViewColumnCollectionChangedEventArgs.cs
- InlineObject.cs
- InputProcessorProfilesLoader.cs
- ListViewSortEventArgs.cs
- OleDbConnectionInternal.cs
- TextEditor.cs
- ResourceDisplayNameAttribute.cs
- RequestQueue.cs
- XmlSchemaCollection.cs
- ChangesetResponse.cs
- WebRequestModulesSection.cs
- FloaterParaClient.cs
- PropertyGeneratedEventArgs.cs
- DesignerResources.cs