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
- IUnknownConstantAttribute.cs
- TraceInternal.cs
- XmlElementList.cs
- ComponentFactoryHelpers.cs
- ApplicationDirectory.cs
- DateTimeAutomationPeer.cs
- Perspective.cs
- PermissionRequestEvidence.cs
- TableRowCollection.cs
- XmlSchema.cs
- PrinterSettings.cs
- DataTrigger.cs
- TriggerBase.cs
- GridItemCollection.cs
- StylusPointProperties.cs
- ReaderWriterLockSlim.cs
- WrapperEqualityComparer.cs
- ManualResetEventSlim.cs
- SoapSchemaMember.cs
- InternalConfigEventArgs.cs
- CharacterMetricsDictionary.cs
- ChildTable.cs
- MachineSettingsSection.cs
- Utility.cs
- SystemIPGlobalStatistics.cs
- TryCatch.cs
- SocketInformation.cs
- TypeBuilderInstantiation.cs
- NetTcpBindingElement.cs
- AuthenticationSchemesHelper.cs
- XmlSerializer.cs
- HttpProfileGroupBase.cs
- TextDecorationCollectionConverter.cs
- _SSPISessionCache.cs
- DrawingCollection.cs
- HttpCookie.cs
- EntityDataSourceMemberPath.cs
- BuildProvidersCompiler.cs
- FileLogRecord.cs
- PersonalizationAdministration.cs
- MessageSecurityVersion.cs
- KeyValueSerializer.cs
- FlowDocument.cs
- SqlDependencyListener.cs
- CacheEntry.cs
- ValidationResult.cs
- Int32.cs
- ClientScriptItemCollection.cs
- SoapClientProtocol.cs
- ClientTarget.cs
- Margins.cs
- Graphics.cs
- TextSpan.cs
- WebPartConnectionsEventArgs.cs
- __ConsoleStream.cs
- NetCodeGroup.cs
- RelationshipSet.cs
- DefaultSettingsSection.cs
- RemoteDebugger.cs
- ObjectReaderCompiler.cs
- DesignerCategoryAttribute.cs
- HttpPostClientProtocol.cs
- FixedTextContainer.cs
- COAUTHINFO.cs
- PersistenceTypeAttribute.cs
- PointAnimationClockResource.cs
- AppSettingsReader.cs
- MailDefinition.cs
- LineUtil.cs
- WebPartDisplayModeCollection.cs
- XamlStyleSerializer.cs
- ServiceOperationParameter.cs
- ListenerHandler.cs
- MobileContainerDesigner.cs
- TriggerActionCollection.cs
- XmlSerializableServices.cs
- DynamicObject.cs
- DPCustomTypeDescriptor.cs
- DuplexSecurityProtocolFactory.cs
- DescendentsWalker.cs
- UnionCqlBlock.cs
- PageRouteHandler.cs
- BooleanFacetDescriptionElement.cs
- WebPartZoneBase.cs
- UIPermission.cs
- BaseProcessProtocolHandler.cs
- ExpandCollapsePattern.cs
- DateTimeUtil.cs
- WindowsSspiNegotiation.cs
- NamespaceDecl.cs
- ResourceDictionary.cs
- UInt32.cs
- ListViewItemEventArgs.cs
- DBConnection.cs
- CheckBox.cs
- LineSegment.cs
- TemplatedAdorner.cs
- InvokeMethodActivity.cs
- ConfigXmlCDataSection.cs
- FloatSumAggregationOperator.cs