The Labs \ Source Viewer \ SSCLI \ System.Net.Configuration \ ServicePointManagerElement

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ServicePointManagerElement.cs" company="Microsoft Corporation">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net.Configuration
  16. {
  17.     using System;
  18.     using System.Configuration;
  19.     using System.Reflection;
  20.     using System.Security.Permissions;
  21.    
  22.     public sealed class ServicePointManagerElement : ConfigurationElement
  23.     {
  24.         public ServicePointManagerElement()
  25.         {
  26.             this.properties.Add(this.checkCertificateName);
  27.             this.properties.Add(this.checkCertificateRevocationList);
  28.             this.properties.Add(this.dnsRefreshTimeout);
  29.             this.properties.Add(this.enableDnsRoundRobin);
  30.             this.properties.Add(this.expect100Continue);
  31.             this.properties.Add(this.useNagleAlgorithm);
  32.         }
  33.        
  34.         protected override void PostDeserialize()
  35.         {
  36.             // Perf optimization. If the configuration is coming from machine.config
  37.             // It is safe and we don't need to check for permissions.
  38.             if (EvaluationContext.IsMachineLevel)
  39.                 return;
  40.            
  41.             PropertyInformation[] protectedProperties = {ElementInformation.Properties[ConfigurationStrings.CheckCertificateName], ElementInformation.Properties[ConfigurationStrings.CheckCertificateRevocationList]};
  42.            
  43.             foreach (PropertyInformation property in protectedProperties)
  44.                 if (property.ValueOrigin == PropertyValueOrigin.SetHere) {
  45.                     try {
  46.                         ExceptionHelper.UnmanagedPermission.Demand();
  47.                     }
  48.                     catch (Exception exception) {
  49.                         throw new ConfigurationErrorsException(SR.GetString(SR.net_config_property_permission, property.Name), exception);
  50.                     }
  51.                 }
  52.         }
  53.        
  54.         [ConfigurationProperty(ConfigurationStrings.CheckCertificateName, DefaultValue = true)]
  55.         public bool CheckCertificateName {
  56.             get { return (bool)this[this.checkCertificateName]; }
  57.             set { this[this.checkCertificateName] = value; }
  58.         }
  59.        
  60.         [ConfigurationProperty(ConfigurationStrings.CheckCertificateRevocationList, DefaultValue = false)]
  61.         public bool CheckCertificateRevocationList {
  62.             get { return (bool)this[this.checkCertificateRevocationList]; }
  63.             set { this[this.checkCertificateRevocationList] = value; }
  64.         }
  65.        
  66.         [ConfigurationProperty(ConfigurationStrings.DnsRefreshTimeout, DefaultValue = (int)(2 * 60 * 1000))]
  67.         public int DnsRefreshTimeout {
  68.             get { return (int)this[this.dnsRefreshTimeout]; }
  69.             set { this[this.dnsRefreshTimeout] = value; }
  70.         }
  71.        
  72.         [ConfigurationProperty(ConfigurationStrings.EnableDnsRoundRobin, DefaultValue = false)]
  73.         public bool EnableDnsRoundRobin {
  74.             get { return (bool)this[this.enableDnsRoundRobin]; }
  75.             set { this[this.enableDnsRoundRobin] = value; }
  76.         }
  77.        
  78.         [ConfigurationProperty(ConfigurationStrings.Expect100Continue, DefaultValue = true)]
  79.         public bool Expect100Continue {
  80.             get { return (bool)this[this.expect100Continue]; }
  81.             set { this[this.expect100Continue] = value; }
  82.         }
  83.        
  84.         [ConfigurationProperty(ConfigurationStrings.UseNagleAlgorithm, DefaultValue = true)]
  85.         public bool UseNagleAlgorithm {
  86.             get { return (bool)this[this.useNagleAlgorithm]; }
  87.             set { this[this.useNagleAlgorithm] = value; }
  88.         }
  89.        
  90.         protected override ConfigurationPropertyCollection Properties {
  91.             get { return this.properties; }
  92.         }
  93.        
  94.         ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
  95.        
  96.         readonly ConfigurationProperty checkCertificateName = new ConfigurationProperty(ConfigurationStrings.CheckCertificateName, typeof(bool), true, ConfigurationPropertyOptions.None);
  97.        
  98.         readonly ConfigurationProperty checkCertificateRevocationList = new ConfigurationProperty(ConfigurationStrings.CheckCertificateRevocationList, typeof(bool), false, ConfigurationPropertyOptions.None);
  99.        
  100.         readonly ConfigurationProperty dnsRefreshTimeout = new ConfigurationProperty(ConfigurationStrings.DnsRefreshTimeout, typeof(int), 2 * 60 * 1000, null, new TimeoutValidator(true), ConfigurationPropertyOptions.None);
  101.        
  102.         readonly ConfigurationProperty enableDnsRoundRobin = new ConfigurationProperty(ConfigurationStrings.EnableDnsRoundRobin, typeof(bool), false, ConfigurationPropertyOptions.None);
  103.        
  104.         readonly ConfigurationProperty expect100Continue = new ConfigurationProperty(ConfigurationStrings.Expect100Continue, typeof(bool), true, ConfigurationPropertyOptions.None);
  105.        
  106.         readonly ConfigurationProperty useNagleAlgorithm = new ConfigurationProperty(ConfigurationStrings.UseNagleAlgorithm, typeof(bool), true, ConfigurationPropertyOptions.None);
  107.     }
  108. }

Developer Fusion