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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="WebProxyScriptElement.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.Security.Permissions;
  20.    
  21.     public sealed class WebProxyScriptElement : ConfigurationElement
  22.     {
  23.         public WebProxyScriptElement()
  24.         {
  25.             this.properties.Add(this.downloadTimeout);
  26.             /* Not used with Managed JScript
  27.             this.properties.Add(this.executionTimeout);
  28.             */           
  29.         }
  30.        
  31.         protected override void PostDeserialize()
  32.         {
  33.             // Perf optimization. If the configuration is coming from machine.config
  34.             // It is safe and we don't need to check for permissions.
  35.             if (EvaluationContext.IsMachineLevel)
  36.                 return;
  37.            
  38.             try {
  39.                 ExceptionHelper.WebPermissionUnrestricted.Demand();
  40.             }
  41.             catch (Exception exception) {
  42.                
  43.                 throw new ConfigurationErrorsException(SR.GetString(SR.net_config_element_permission, ConfigurationStrings.WebProxyScript), exception);
  44.             }
  45.         }
  46.        
  47.         [ConfigurationProperty(ConfigurationStrings.DownloadTimeout, DefaultValue = "00:02:00")]
  48.         public TimeSpan DownloadTimeout {
  49.             get { return (TimeSpan)this[this.downloadTimeout]; }
  50.             set { this[this.downloadTimeout] = value; }
  51.         }
  52.        
  53. /* Not used with Managed JScript
  54.         [ConfigurationProperty(ConfigurationStrings.ExecutionTimeout, DefaultValue = "00:00:05")]
  55.         public TimeSpan ExecutionTimeout
  56.         {
  57.             get { return (TimeSpan) this[this.executionTimeout]; }
  58.             set { this[this.executionTimeout] = value; }
  59.         }
  60. */       
  61.        
  62.         protected override ConfigurationPropertyCollection Properties {
  63.             get { return this.properties; }
  64.         }
  65.        
  66.         ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
  67.        
  68.         readonly ConfigurationProperty downloadTimeout = new ConfigurationProperty(ConfigurationStrings.DownloadTimeout, typeof(TimeSpan), TimeSpan.FromMinutes(1), ConfigurationPropertyOptions.None);
  69.        
  70.         /* Not used with Managed JScript
  71.         readonly ConfigurationProperty executionTimeout =
  72.             new ConfigurationProperty(ConfigurationStrings.ExecutionTimeout,
  73.                                       typeof(TimeSpan),
  74.                                       TimeSpan.FromSeconds(5),
  75.                                       ConfigurationPropertyOptions.None);
  76. */       
  77.     }
  78. }

Developer Fusion