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
- HtmlTextArea.cs
- TypeUtil.cs
- TextBlockAutomationPeer.cs
- FixedDSBuilder.cs
- PartialArray.cs
- X509SubjectKeyIdentifierClause.cs
- RectangleHotSpot.cs
- TypeDescriptor.cs
- DataGridSortCommandEventArgs.cs
- DataBoundLiteralControl.cs
- DataKey.cs
- ListControlConvertEventArgs.cs
- WithStatement.cs
- PlacementWorkspace.cs
- ScopedMessagePartSpecification.cs
- LogEntry.cs
- GeneralTransformGroup.cs
- TextSpan.cs
- BuiltInExpr.cs
- DbSetClause.cs
- SafeTimerHandle.cs
- SchemaElementDecl.cs
- MultiTrigger.cs
- ObjectKeyFrameCollection.cs
- GridViewColumnHeader.cs
- FixUp.cs
- CustomErrorsSectionWrapper.cs
- EntityClientCacheKey.cs
- NonVisualControlAttribute.cs
- ResourceProperty.cs
- ResetableIterator.cs
- RegexGroupCollection.cs
- SiteMapSection.cs
- Section.cs
- ResXDataNode.cs
- XmlSerializationGeneratedCode.cs
- AddInSegmentDirectoryNotFoundException.cs
- InvalidOperationException.cs
- DesignerTransactionCloseEvent.cs
- ComponentConverter.cs
- Popup.cs
- ResourceExpression.cs
- PlatformCulture.cs
- _SecureChannel.cs
- DomNameTable.cs
- FacetDescriptionElement.cs
- UnhandledExceptionEventArgs.cs
- CreateParams.cs
- Translator.cs
- ProxySimple.cs
- SignatureHelper.cs
- FormParameter.cs
- AuthenticationConfig.cs
- SchemaImporter.cs
- EventMap.cs
- XamlDesignerSerializationManager.cs
- RsaSecurityToken.cs
- WebControlsSection.cs
- KeyToListMap.cs
- DocumentAutomationPeer.cs
- UnsafeNativeMethodsMilCoreApi.cs
- UnmanagedBitmapWrapper.cs
- FixedNode.cs
- WeakReference.cs
- ApplicationSettingsBase.cs
- FastPropertyAccessor.cs
- StrongNameUtility.cs
- RemoteWebConfigurationHostServer.cs
- WindowsScrollBar.cs
- TdsEnums.cs
- SqlDataSourceQuery.cs
- Viewport3DAutomationPeer.cs
- SqlMetaData.cs
- DataControlLinkButton.cs
- Identifier.cs
- DataGridViewRowErrorTextNeededEventArgs.cs
- MetadataArtifactLoader.cs
- SqlFileStream.cs
- PropertyPathConverter.cs
- CustomWebEventKey.cs
- DesignerOptionService.cs
- FixedSOMLineCollection.cs
- PrivilegeNotHeldException.cs
- Inflater.cs
- SqlStream.cs
- ADMembershipUser.cs
- DaylightTime.cs
- Internal.cs
- QueueTransferProtocol.cs
- DesignTimeHTMLTextWriter.cs
- StorageConditionPropertyMapping.cs
- ContainerSelectorActiveEvent.cs
- LoaderAllocator.cs
- ResourceDescriptionAttribute.cs
- ShutDownListener.cs
- EncryptedPackage.cs
- Pen.cs
- MaskedTextProvider.cs
- _RequestCacheProtocol.cs
- DataSourceCacheDurationConverter.cs