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
- DbConnectionStringCommon.cs
- DetailsViewRowCollection.cs
- PersonalizationStateQuery.cs
- BindingCompleteEventArgs.cs
- SplayTreeNode.cs
- Int32.cs
- versioninfo.cs
- StringDictionary.cs
- Command.cs
- MatrixAnimationUsingKeyFrames.cs
- ViewStateModeByIdAttribute.cs
- ContextMenuService.cs
- CustomAttributeFormatException.cs
- SchemaElementLookUpTable.cs
- ItemMap.cs
- DispatcherFrame.cs
- ReferenceConverter.cs
- MemoryMappedFileSecurity.cs
- QilDataSource.cs
- FastEncoderStatics.cs
- DataGrid.cs
- PropertyDescriptorComparer.cs
- InfoCardRSAPKCS1KeyExchangeFormatter.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- AttachmentService.cs
- SessionPageStatePersister.cs
- DataList.cs
- SectionInput.cs
- BrowsableAttribute.cs
- IssuanceLicense.cs
- RawStylusInputReport.cs
- ConfigurationLocationCollection.cs
- FixedSOMImage.cs
- AutomationPropertyChangedEventArgs.cs
- TimerEventSubscription.cs
- ViewStateAttachedPropertyFeature.cs
- MethodToken.cs
- ExpressionBuilderCollection.cs
- SoapElementAttribute.cs
- SafeNativeMethods.cs
- CompositeActivityMarkupSerializer.cs
- Matrix3D.cs
- HttpValueCollection.cs
- BamlTreeNode.cs
- WebPartsSection.cs
- LongCountAggregationOperator.cs
- KeyGestureValueSerializer.cs
- FormatConvertedBitmap.cs
- DataColumnChangeEvent.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- AssemblyBuilder.cs
- RequestSecurityToken.cs
- MetadataItemEmitter.cs
- SelectionListComponentEditor.cs
- ReadWriteObjectLock.cs
- WindowsIdentity.cs
- ListSortDescription.cs
- X500Name.cs
- WebPartTransformerAttribute.cs
- ClickablePoint.cs
- BoundField.cs
- WebDisplayNameAttribute.cs
- OneOf.cs
- PathFigureCollectionValueSerializer.cs
- ResourceAttributes.cs
- AccessorTable.cs
- ScalarConstant.cs
- GetKeyedHashRequest.cs
- UnconditionalPolicy.cs
- DynamicQueryableWrapper.cs
- DoubleStorage.cs
- StaticContext.cs
- ScrollProperties.cs
- SparseMemoryStream.cs
- Brush.cs
- PerformanceCounterCategory.cs
- HttpCacheVaryByContentEncodings.cs
- ellipse.cs
- AssemblyEvidenceFactory.cs
- DataGridHeaderBorder.cs
- Matrix.cs
- EntityDataSourceView.cs
- ReadOnlyPermissionSet.cs
- XmlAttributeAttribute.cs
- RenderDataDrawingContext.cs
- DependencySource.cs
- ApplicationDirectory.cs
- ScrollItemPattern.cs
- UnsafeNativeMethodsMilCoreApi.cs
- XmlSchemaInclude.cs
- Int16Storage.cs
- AssociationSetEnd.cs
- RuleInfoComparer.cs
- AsyncOperation.cs
- MenuEventArgs.cs
- TextCollapsingProperties.cs
- AbandonedMutexException.cs
- Rotation3DAnimationBase.cs
- AppSecurityManager.cs
- DataPointer.cs