Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// 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;
}
}
// 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
- BindingNavigator.cs
- SingleAnimation.cs
- BinHexDecoder.cs
- WindowsListViewGroup.cs
- PointAnimationUsingKeyFrames.cs
- CommaDelimitedStringAttributeCollectionConverter.cs
- DataServiceClientException.cs
- BordersPage.cs
- Function.cs
- CompositeTypefaceMetrics.cs
- SqlNodeAnnotations.cs
- ToolStripItemTextRenderEventArgs.cs
- IpcChannelHelper.cs
- XmlUnspecifiedAttribute.cs
- Base64Stream.cs
- CommandDevice.cs
- OdbcEnvironment.cs
- FormViewDeletedEventArgs.cs
- XPathMultyIterator.cs
- Msec.cs
- CollectionBase.cs
- MimeBasePart.cs
- HeaderCollection.cs
- DocumentEventArgs.cs
- DescendantQuery.cs
- MsmqIntegrationOutputChannel.cs
- CursorConverter.cs
- TemplateBuilder.cs
- ConvertEvent.cs
- ObjectListGeneralPage.cs
- CustomCategoryAttribute.cs
- CorrelationToken.cs
- CardSpaceShim.cs
- BoundingRectTracker.cs
- XmlTextReaderImplHelpers.cs
- IMembershipProvider.cs
- Descriptor.cs
- AnnotationResource.cs
- UntypedNullExpression.cs
- CustomUserNameSecurityTokenAuthenticator.cs
- AlignmentYValidation.cs
- _NetRes.cs
- MulticastOption.cs
- XmlAnyElementAttribute.cs
- ResourceCollectionInfo.cs
- DecimalStorage.cs
- GrammarBuilder.cs
- DataViewSetting.cs
- ObjectDisposedException.cs
- QilLoop.cs
- CAGDesigner.cs
- ParseNumbers.cs
- ReturnType.cs
- CodeRegionDirective.cs
- SamlAdvice.cs
- PropertyPath.cs
- IRCollection.cs
- PathFigureCollection.cs
- PublisherMembershipCondition.cs
- ProfilePropertySettings.cs
- IgnoreFileBuildProvider.cs
- ControlBindingsCollection.cs
- PermissionSet.cs
- CodeCommentStatementCollection.cs
- ExitEventArgs.cs
- EdmToObjectNamespaceMap.cs
- SqlError.cs
- ExtensibleClassFactory.cs
- graph.cs
- oledbconnectionstring.cs
- ViewBox.cs
- FixedSOMImage.cs
- Sql8ConformanceChecker.cs
- CodeGroup.cs
- ZipIORawDataFileBlock.cs
- XmlEncodedRawTextWriter.cs
- WebPartConnectionsEventArgs.cs
- CodeAttachEventStatement.cs
- CodeGeneratorOptions.cs
- BindingCollection.cs
- coordinator.cs
- DispatchOperationRuntime.cs
- StoreItemCollection.cs
- serverconfig.cs
- MetadataArtifactLoaderCompositeFile.cs
- FtpCachePolicyElement.cs
- GeneralTransform.cs
- PrintDialogDesigner.cs
- CompositeDataBoundControl.cs
- LinkArea.cs
- updatecommandorderer.cs
- DataTrigger.cs
- UICuesEvent.cs
- XPathNodeHelper.cs
- ScopeElementCollection.cs
- UIElementPropertyUndoUnit.cs
- ExtendedPropertyInfo.cs
- CodeGenerator.cs
- FileDialogPermission.cs
- PerformanceCounterPermission.cs