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
- XmlEventCache.cs
- XmlReaderSettings.cs
- HttpListenerPrefixCollection.cs
- DiscoveryDocumentSearchPattern.cs
- WmlTextViewAdapter.cs
- HtmlForm.cs
- StorageMappingItemLoader.cs
- PageHandlerFactory.cs
- SQLMoney.cs
- NoClickablePointException.cs
- ExpressionVisitor.cs
- ProcessThreadCollection.cs
- HtmlHistory.cs
- ObjectQueryState.cs
- IImplicitResourceProvider.cs
- DefaultEvaluationContext.cs
- ApplicationSettingsBase.cs
- TextBox.cs
- CompiledQueryCacheKey.cs
- CalendarItem.cs
- XmlFormatReaderGenerator.cs
- WebPartEditorCancelVerb.cs
- XmlDataSourceView.cs
- PipelineModuleStepContainer.cs
- SQLResource.cs
- BinaryVersion.cs
- FragmentQuery.cs
- TextElement.cs
- SizeConverter.cs
- HTTPNotFoundHandler.cs
- InkCanvasAutomationPeer.cs
- _NTAuthentication.cs
- CodeSnippetCompileUnit.cs
- IteratorFilter.cs
- UnknownExceptionActionHelper.cs
- DataGridColumnCollection.cs
- _DisconnectOverlappedAsyncResult.cs
- TransactionScope.cs
- EventLogPropertySelector.cs
- LogRestartAreaEnumerator.cs
- CompiledRegexRunnerFactory.cs
- ProxyAttribute.cs
- ICspAsymmetricAlgorithm.cs
- IgnoreFlushAndCloseStream.cs
- FixedLineResult.cs
- RoutedEvent.cs
- IdentityManager.cs
- XPathAxisIterator.cs
- ProxyWebPartManager.cs
- MLangCodePageEncoding.cs
- DecimalAnimationUsingKeyFrames.cs
- CompensatableSequenceActivity.cs
- WorkflowServiceHost.cs
- WebZone.cs
- DataGridCaption.cs
- SchemaNames.cs
- DataShape.cs
- ComplexTypeEmitter.cs
- RowToFieldTransformer.cs
- ReferentialConstraint.cs
- sqlcontext.cs
- ProcessModule.cs
- SqlBooleanizer.cs
- AttributeParameterInfo.cs
- ToolBarOverflowPanel.cs
- DataSourceCacheDurationConverter.cs
- InputDevice.cs
- HwndTarget.cs
- ZipArchive.cs
- ValueOfAction.cs
- Win32Exception.cs
- CodeAttributeArgumentCollection.cs
- EventListenerClientSide.cs
- StateValidator.cs
- DoubleKeyFrameCollection.cs
- BamlBinaryWriter.cs
- ConditionalAttribute.cs
- PageTheme.cs
- CacheHelper.cs
- SQLBoolean.cs
- GeometryGroup.cs
- StreamGeometry.cs
- BamlLocalizationDictionary.cs
- StorageAssociationTypeMapping.cs
- DataTable.cs
- NamespaceMapping.cs
- X509CertificateChain.cs
- XamlGridLengthSerializer.cs
- XPathCompileException.cs
- HostedAspNetEnvironment.cs
- QilStrConcat.cs
- BindingCollection.cs
- LookupNode.cs
- DrawingAttributeSerializer.cs
- SqlClientFactory.cs
- WebPartManagerInternals.cs
- OraclePermissionAttribute.cs
- NativeWindow.cs
- SimpleMailWebEventProvider.cs
- XamlRtfConverter.cs