Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / TrustUi / MS / Internal / documents / Application / AddressUtility.cs / 1 / AddressUtility.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: // A collection of utility functions for dealing with e-mail address // strings and Uri objects. // // History: // 10/26/05 - [....] created // //--------------------------------------------------------------------------- using System; using System.Globalization; using System.Text.RegularExpressions; using MS.Internal.WindowsBase; namespace MS.Internal.Documents { ////// A collection of utility functions for dealing with e-mail address /// strings and Uri objects. /// internal static class AddressUtility { #region Internal Methods //----------------------------------------------------- // Internal Methods //----------------------------------------------------- ////// Checks if the scheme of the URI given is of the mailto scheme. /// /// The URI to check ///Whether or not it is a mailto URI internal static bool IsMailtoUri(Uri mailtoUri) { if (mailtoUri != null) { return SecurityHelper.AreStringTypesEqual( mailtoUri.Scheme, Uri.UriSchemeMailto); } return false; } ////// Gets the e-mail address from the URI given. /// /// The URI ///The e-mail address internal static string GetEmailAddressFromMailtoUri(Uri mailtoUri) { string address = string.Empty; // Ensure it is a mailto: scheme URI if (IsMailtoUri(mailtoUri)) { // Create the address from the URI address = string.Format( CultureInfo.CurrentCulture, _addressTemplate, mailtoUri.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped), mailtoUri.GetComponents(UriComponents.Host, UriFormat.Unescaped)); } return address; } ////// Generate a mailto: URI from the e-mail address given as an /// argument. /// /// The address to generate a URI from ///The generated URI internal static Uri GenerateMailtoUri(string address) { // Add the scheme to the e-mail address to form a URI object if (!string.IsNullOrEmpty(address)) { return new Uri(string.Format( CultureInfo.CurrentCulture, _mailtoUriTemplate, Uri.UriSchemeMailto, _mailtoSchemeDelimiter, address)); } return null; } #endregion Internal Methods #region Private Fields //-------------------------------------------------------------------------- // Private Fields //------------------------------------------------------------------------- ////// The template for an e-mail address with a user name and a host. /// private const string _addressTemplate = "{0}@{1}"; ////// The template for a mailto scheme URI with the mailto scheme and an /// address. /// private const string _mailtoUriTemplate = "{0}{1}{2}"; ////// The delimiter between the scheme and the address in a mailto URI. /// We unfortunately cannot use the Uri class SchemeDelimiter because /// it is by default set to "://", which makes mailto: URIs generated /// look like "mailto://user@host", whicn in turn cannot be parsed /// properly by this class. /// private const string _mailtoSchemeDelimiter = ":"; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UnsafeNativeMethods.cs
- AppDomain.cs
- JournalEntryStack.cs
- ColumnHeaderConverter.cs
- PageCatalogPart.cs
- XmlKeywords.cs
- CustomCategoryAttribute.cs
- GridViewEditEventArgs.cs
- OracleCommandSet.cs
- CombinedTcpChannel.cs
- PerfCounters.cs
- XmlSchemaInclude.cs
- SqlDataRecord.cs
- MonthChangedEventArgs.cs
- Process.cs
- JoinSymbol.cs
- DiscardableAttribute.cs
- TypeConverterHelper.cs
- WebBrowserContainer.cs
- HttpContext.cs
- ThreadStartException.cs
- EmissiveMaterial.cs
- securitycriticaldata.cs
- HttpTransportSecurityElement.cs
- PropertyManager.cs
- KeyedPriorityQueue.cs
- DbgCompiler.cs
- TextTreeInsertElementUndoUnit.cs
- XmlWriterTraceListener.cs
- SequentialUshortCollection.cs
- XmlReflectionMember.cs
- TrackBarRenderer.cs
- OletxCommittableTransaction.cs
- CircleHotSpot.cs
- WebMessageEncodingElement.cs
- Region.cs
- TheQuery.cs
- MimeMultiPart.cs
- RadioButtonStandardAdapter.cs
- ConfigurationException.cs
- SafeFileMappingHandle.cs
- ContainerUtilities.cs
- Trace.cs
- ReadOnlyDictionary.cs
- BitHelper.cs
- LassoSelectionBehavior.cs
- AdRotator.cs
- UpDownBase.cs
- ExpressionList.cs
- ViewCellRelation.cs
- WebMessageFormatHelper.cs
- Native.cs
- MiniLockedBorderGlyph.cs
- RegisteredArrayDeclaration.cs
- WmpBitmapEncoder.cs
- Encoder.cs
- PresentationAppDomainManager.cs
- StrokeNode.cs
- ButtonBase.cs
- DynamicResourceExtensionConverter.cs
- DrawingImage.cs
- Empty.cs
- Italic.cs
- UserUseLicenseDictionaryLoader.cs
- XmlSchemaComplexContentExtension.cs
- UnorderedHashRepartitionStream.cs
- PlainXmlWriter.cs
- RadioButtonStandardAdapter.cs
- TriState.cs
- MdiWindowListItemConverter.cs
- StringFunctions.cs
- PageFunction.cs
- DebugViewWriter.cs
- TraceSource.cs
- LocalizationComments.cs
- ToolStripDropDownMenu.cs
- ProcessModelSection.cs
- TransformGroup.cs
- FileNotFoundException.cs
- RegistryKey.cs
- NativeMethods.cs
- XmlTextAttribute.cs
- BitmapEffectState.cs
- XamlGridLengthSerializer.cs
- PrtTicket_Public.cs
- SignatureHelper.cs
- TabControl.cs
- WebSysDisplayNameAttribute.cs
- ClientProtocol.cs
- StructuredProperty.cs
- XmlDesigner.cs
- MenuStrip.cs
- EasingQuaternionKeyFrame.cs
- ResourcesChangeInfo.cs
- TextDpi.cs
- OleDbPermission.cs
- NameValueCollection.cs
- DiagnosticTraceSource.cs
- ToolboxComponentsCreatedEventArgs.cs
- WebPartMenuStyle.cs