Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Net / System / Net / Configuration / SocketElement.cs / 1305376 / SocketElement.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Net.Configuration
{
using System;
using System.Configuration;
using System.Net.Sockets;
using System.Reflection;
using System.Security.Permissions;
public sealed class SocketElement : ConfigurationElement
{
public SocketElement()
{
this.properties.Add(this.alwaysUseCompletionPortsForAccept);
this.properties.Add(this.alwaysUseCompletionPortsForConnect);
this.properties.Add(this.ipProtectionLevel);
}
protected override void PostDeserialize()
{
// Perf optimization. If the configuration is coming from machine.config
// It is safe and we don't need to check for permissions.
if (EvaluationContext.IsMachineLevel)
return;
try {
ExceptionHelper.UnrestrictedSocketPermission.Demand();
} catch (Exception exception) {
throw new ConfigurationErrorsException(
SR.GetString(SR.net_config_element_permission,
ConfigurationStrings.Socket),
exception);
}
}
[ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForAccept, DefaultValue = false)]
public bool AlwaysUseCompletionPortsForAccept
{
get { return (bool)this[this.alwaysUseCompletionPortsForAccept]; }
set { this[this.alwaysUseCompletionPortsForAccept] = value; }
}
[ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForConnect, DefaultValue = false)]
public bool AlwaysUseCompletionPortsForConnect
{
get { return (bool)this[this.alwaysUseCompletionPortsForConnect]; }
set { this[this.alwaysUseCompletionPortsForConnect] = value; }
}
[ConfigurationProperty(ConfigurationStrings.IPProtectionLevel, DefaultValue = IPProtectionLevel.Unspecified)]
public IPProtectionLevel IPProtectionLevel
{
get { return (IPProtectionLevel)this[this.ipProtectionLevel]; }
set { this[this.ipProtectionLevel] = value; }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return this.properties;
}
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty alwaysUseCompletionPortsForConnect =
new ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForConnect, typeof(bool), false,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty alwaysUseCompletionPortsForAccept =
new ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForAccept, typeof(bool), false,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty ipProtectionLevel =
new ConfigurationProperty(ConfigurationStrings.IPProtectionLevel, typeof(IPProtectionLevel),
IPProtectionLevel.Unspecified, ConfigurationPropertyOptions.None);
}
}
// 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.Net.Sockets;
using System.Reflection;
using System.Security.Permissions;
public sealed class SocketElement : ConfigurationElement
{
public SocketElement()
{
this.properties.Add(this.alwaysUseCompletionPortsForAccept);
this.properties.Add(this.alwaysUseCompletionPortsForConnect);
this.properties.Add(this.ipProtectionLevel);
}
protected override void PostDeserialize()
{
// Perf optimization. If the configuration is coming from machine.config
// It is safe and we don't need to check for permissions.
if (EvaluationContext.IsMachineLevel)
return;
try {
ExceptionHelper.UnrestrictedSocketPermission.Demand();
} catch (Exception exception) {
throw new ConfigurationErrorsException(
SR.GetString(SR.net_config_element_permission,
ConfigurationStrings.Socket),
exception);
}
}
[ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForAccept, DefaultValue = false)]
public bool AlwaysUseCompletionPortsForAccept
{
get { return (bool)this[this.alwaysUseCompletionPortsForAccept]; }
set { this[this.alwaysUseCompletionPortsForAccept] = value; }
}
[ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForConnect, DefaultValue = false)]
public bool AlwaysUseCompletionPortsForConnect
{
get { return (bool)this[this.alwaysUseCompletionPortsForConnect]; }
set { this[this.alwaysUseCompletionPortsForConnect] = value; }
}
[ConfigurationProperty(ConfigurationStrings.IPProtectionLevel, DefaultValue = IPProtectionLevel.Unspecified)]
public IPProtectionLevel IPProtectionLevel
{
get { return (IPProtectionLevel)this[this.ipProtectionLevel]; }
set { this[this.ipProtectionLevel] = value; }
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return this.properties;
}
}
ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
readonly ConfigurationProperty alwaysUseCompletionPortsForConnect =
new ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForConnect, typeof(bool), false,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty alwaysUseCompletionPortsForAccept =
new ConfigurationProperty(ConfigurationStrings.AlwaysUseCompletionPortsForAccept, typeof(bool), false,
ConfigurationPropertyOptions.None);
readonly ConfigurationProperty ipProtectionLevel =
new ConfigurationProperty(ConfigurationStrings.IPProtectionLevel, typeof(IPProtectionLevel),
IPProtectionLevel.Unspecified, ConfigurationPropertyOptions.None);
}
}
// 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
- ViewBase.cs
- ProfileSettingsCollection.cs
- ArrayWithOffset.cs
- FontNamesConverter.cs
- ServiceObjectContainer.cs
- BrushConverter.cs
- EntityDesignPluralizationHandler.cs
- TraceRecord.cs
- _ProxyChain.cs
- Volatile.cs
- CustomGrammar.cs
- DataTableReader.cs
- PolicyUtility.cs
- _SSPISessionCache.cs
- OpCodes.cs
- SafePointer.cs
- Point3DAnimation.cs
- Columns.cs
- DataGridViewTextBoxColumn.cs
- XmlValidatingReader.cs
- SqlCommand.cs
- BatchServiceHost.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- DrawItemEvent.cs
- Cursors.cs
- FileLogRecordStream.cs
- AppSettingsSection.cs
- DataServiceRequest.cs
- GroupItemAutomationPeer.cs
- DesignerDataSchemaClass.cs
- SoapObjectReader.cs
- DataSourceCache.cs
- ButtonColumn.cs
- PopupRoot.cs
- ProcessHostServerConfig.cs
- Shape.cs
- TraceRecords.cs
- SectionUpdates.cs
- PointAnimationUsingPath.cs
- ObjectCacheSettings.cs
- DefaultProxySection.cs
- StringSource.cs
- MergeFailedEvent.cs
- PackWebRequest.cs
- AutoGeneratedFieldProperties.cs
- DocumentReference.cs
- ReferentialConstraint.cs
- MdImport.cs
- OracleRowUpdatedEventArgs.cs
- DefaultHttpHandler.cs
- AmbientProperties.cs
- ChangeNode.cs
- WeakReadOnlyCollection.cs
- TraceUtils.cs
- CrossContextChannel.cs
- EntityRecordInfo.cs
- controlskin.cs
- MessagingDescriptionAttribute.cs
- ButtonAutomationPeer.cs
- TableLayoutPanelCellPosition.cs
- DispatcherOperation.cs
- PrinterUnitConvert.cs
- TextFormatterContext.cs
- reliableinputsessionchannel.cs
- LayoutTableCell.cs
- ObjectDisposedException.cs
- _HelperAsyncResults.cs
- DbBuffer.cs
- TdsParserStaticMethods.cs
- NamedObjectList.cs
- Command.cs
- BuildResultCache.cs
- remotingproxy.cs
- WpfXamlLoader.cs
- DragEvent.cs
- ClientBuildManager.cs
- AuthenticationServiceManager.cs
- LayoutTableCell.cs
- ConfigXmlAttribute.cs
- Range.cs
- GridItemProviderWrapper.cs
- SqlRetyper.cs
- DocobjHost.cs
- DocumentReferenceCollection.cs
- AuthorizationRuleCollection.cs
- DataControlLinkButton.cs
- Crc32Helper.cs
- HostedElements.cs
- WebWorkflowRole.cs
- GroupBox.cs
- AssemblyBuilder.cs
- GroupBoxAutomationPeer.cs
- ScriptReferenceBase.cs
- SrgsItemList.cs
- ScriptControlManager.cs
- SafeUserTokenHandle.cs
- ZoneMembershipCondition.cs
- GACMembershipCondition.cs
- XmlEventCache.cs
- WindowsListViewGroup.cs