Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Configuration / SmtpSection.cs / 1 / SmtpSection.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net.Configuration { using System; using System.Configuration; using System.ComponentModel; using System.Globalization; using System.Net; using System.Net.Mail; using System.Reflection; using System.Threading; public sealed class SmtpSection : ConfigurationSection { public SmtpSection() { this.properties.Add(this.deliveryMethod); this.properties.Add(this.from); this.properties.Add(this.network); this.properties.Add(this.specifiedPickupDirectory); } [ConfigurationProperty(ConfigurationStrings.DeliveryMethod, DefaultValue = (SmtpDeliveryMethod) SmtpDeliveryMethod.Network)] public SmtpDeliveryMethod DeliveryMethod { get { return (SmtpDeliveryMethod)this[this.deliveryMethod]; } set { this[this.deliveryMethod] = value; } } [ConfigurationProperty(ConfigurationStrings.From)] public string From { get { return (string)this[this.from]; } set { this[this.from] = value; } } [ConfigurationProperty(ConfigurationStrings.Network)] public SmtpNetworkElement Network { get { return (SmtpNetworkElement)this[this.network]; } } [ConfigurationProperty(ConfigurationStrings.SpecifiedPickupDirectory)] public SmtpSpecifiedPickupDirectoryElement SpecifiedPickupDirectory { get { return (SmtpSpecifiedPickupDirectoryElement)this[this.specifiedPickupDirectory]; } } protected override ConfigurationPropertyCollection Properties { get { return this.properties; } } // ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); readonly ConfigurationProperty from = new ConfigurationProperty(ConfigurationStrings.From, typeof(string), null, ConfigurationPropertyOptions.None); readonly ConfigurationProperty network = new ConfigurationProperty(ConfigurationStrings.Network, typeof(SmtpNetworkElement), null, ConfigurationPropertyOptions.None); readonly ConfigurationProperty specifiedPickupDirectory = new ConfigurationProperty(ConfigurationStrings.SpecifiedPickupDirectory, typeof(SmtpSpecifiedPickupDirectoryElement), null, ConfigurationPropertyOptions.None); readonly ConfigurationProperty deliveryMethod = new ConfigurationProperty(ConfigurationStrings.DeliveryMethod, typeof(SmtpDeliveryMethod), SmtpDeliveryMethod.Network, new SmtpDeliveryMethodTypeConverter(), null, ConfigurationPropertyOptions.None); class SmtpDeliveryMethodTypeConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { return true; } return base.CanConvertFrom(context, sourceType); } public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { string s = value as string; if (s != null) { s = s.ToLower(CultureInfo.InvariantCulture); switch (s) { case "network": return SmtpDeliveryMethod.Network; case "specifiedpickupdirectory": return SmtpDeliveryMethod.SpecifiedPickupDirectory; #if !FEATURE_PAL case "pickupdirectoryfromiis": return SmtpDeliveryMethod.PickupDirectoryFromIis; #endif } } return base.ConvertFrom(context, culture, value); } } } internal sealed class SmtpSectionInternal { internal SmtpSectionInternal(SmtpSection section) { this.deliveryMethod = section.DeliveryMethod; this.from = section.From; this.network = new SmtpNetworkElementInternal(section.Network); this.specifiedPickupDirectory = new SmtpSpecifiedPickupDirectoryElementInternal(section.SpecifiedPickupDirectory); } internal SmtpDeliveryMethod DeliveryMethod { get { return this.deliveryMethod; } } internal SmtpNetworkElementInternal Network { get { return this.network; } } internal string From { get { return this.from; } } internal SmtpSpecifiedPickupDirectoryElementInternal SpecifiedPickupDirectory { get { return this.specifiedPickupDirectory; } } SmtpDeliveryMethod deliveryMethod; string from = null; SmtpNetworkElementInternal network = null; SmtpSpecifiedPickupDirectoryElementInternal specifiedPickupDirectory = null; internal static object ClassSyncObject { get { if (classSyncObject == null) { Interlocked.CompareExchange(ref classSyncObject, new object(), null); } return classSyncObject; } } internal static SmtpSectionInternal GetSection() { lock (ClassSyncObject) { SmtpSection section = PrivilegedConfigurationManager.GetSection(ConfigurationStrings.SmtpSectionPath) as SmtpSection; if (section == null) return null; return new SmtpSectionInternal(section); } } private static object classSyncObject; } }
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlNamespaceMappingCollection.cs
- FileVersionInfo.cs
- MetafileHeader.cs
- Double.cs
- TextCompositionEventArgs.cs
- MonitoringDescriptionAttribute.cs
- BinaryReader.cs
- Hashtable.cs
- X509WindowsSecurityToken.cs
- SpecialNameAttribute.cs
- ErasingStroke.cs
- SBCSCodePageEncoding.cs
- DataObjectMethodAttribute.cs
- ProcessModuleCollection.cs
- LayoutUtils.cs
- WebBrowser.cs
- QueryOutputWriter.cs
- ProfileManager.cs
- SafeRightsManagementSessionHandle.cs
- Qualifier.cs
- SqlGenericUtil.cs
- ListView.cs
- XsltSettings.cs
- TagMapInfo.cs
- CompilerState.cs
- DataContractJsonSerializer.cs
- MultipleViewPattern.cs
- OdbcFactory.cs
- CompletionProxy.cs
- TypeConverterAttribute.cs
- Columns.cs
- ListViewSelectEventArgs.cs
- LineVisual.cs
- TreeViewDataItemAutomationPeer.cs
- MbpInfo.cs
- TextTrailingWordEllipsis.cs
- XmlObjectSerializerReadContextComplex.cs
- SystemResourceHost.cs
- ExtensionElementCollection.cs
- WebPartEditVerb.cs
- DrawListViewItemEventArgs.cs
- BrowserCapabilitiesCompiler.cs
- Socket.cs
- TagMapCollection.cs
- TextEditorSpelling.cs
- WindowsToolbarAsMenu.cs
- SemanticKeyElement.cs
- ListView.cs
- Base64WriteStateInfo.cs
- PropertySegmentSerializer.cs
- DataGridItem.cs
- SafeCryptContextHandle.cs
- ViewManager.cs
- SecurityProtocolFactory.cs
- BufferedGraphics.cs
- DriveNotFoundException.cs
- PropertyToken.cs
- KeyValueConfigurationCollection.cs
- _SslStream.cs
- DataGridViewSelectedColumnCollection.cs
- __Error.cs
- WriteTimeStream.cs
- GestureRecognitionResult.cs
- ConfigurationManagerInternalFactory.cs
- EntryIndex.cs
- ExtenderControl.cs
- InvokePattern.cs
- TimeSpanSecondsConverter.cs
- PathFigureCollectionConverter.cs
- DesignerTransaction.cs
- SecurityPolicySection.cs
- AttributeUsageAttribute.cs
- HtmlWindow.cs
- ObjectDataSourceView.cs
- WebZone.cs
- SqlBooleanMismatchVisitor.cs
- FillRuleValidation.cs
- BaseValidator.cs
- VersionPair.cs
- GroupByQueryOperator.cs
- ListManagerBindingsCollection.cs
- PropertyItemInternal.cs
- PenCursorManager.cs
- ImageList.cs
- DbTransaction.cs
- SamlAction.cs
- namescope.cs
- WebPartTracker.cs
- Base64Stream.cs
- WebPartDisplayModeCollection.cs
- HttpValueCollection.cs
- ModifiableIteratorCollection.cs
- XmlILAnnotation.cs
- XmlDataDocument.cs
- Oci.cs
- entityreference_tresulttype.cs
- UIElementIsland.cs
- Visual.cs
- DecimalFormatter.cs
- ToolStripItemRenderEventArgs.cs