1 //------------------------------------------------------------------------------ 2 // <copyright file="ProxyElement.cs" company="Microsoft Corporation"> 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // </copyright> 5 //------------------------------------------------------------------------------ 6 7 namespace System.Net.Configuration 8 { 9 using System; 10 using System.Xml; 11 using System.Configuration; 12 using System.Reflection; 13 using System.ComponentModel; 14 using System.Security.Permissions; 15 16 public sealed class ProxyElement : ConfigurationElement 17 { 18 public enum BypassOnLocalValues 19 { 20 Unspecified = -1, 21 False = 0, 22 True = 1, 23 } 24 25 public enum UseSystemDefaultValues 26 { 27 Unspecified = -1, 28 False = 0, 29 True = 1, 30 } 31 32 public enum AutoDetectValues 33 { 34 Unspecified = -1, 35 False = 0, 36 True = 1, 37 } 38 ProxyElement()39 public ProxyElement() 40 { 41 this.properties.Add(this.autoDetect); 42 this.properties.Add(this.scriptLocation); 43 this.properties.Add(this.bypassonlocal); 44 this.properties.Add(this.proxyaddress); 45 this.properties.Add(this.usesystemdefault); 46 } 47 48 protected override ConfigurationPropertyCollection Properties 49 { 50 get 51 { 52 return this.properties; 53 } 54 } 55 56 [ConfigurationProperty(ConfigurationStrings.AutoDetect, DefaultValue=AutoDetectValues.Unspecified)] 57 public AutoDetectValues AutoDetect 58 { 59 get { return (AutoDetectValues)this[this.autoDetect]; } 60 set { this[this.autoDetect] = value; } 61 } 62 63 [ConfigurationProperty(ConfigurationStrings.ScriptLocation)] 64 public Uri ScriptLocation 65 { 66 get { return (Uri)this[this.scriptLocation]; } 67 set { this[this.scriptLocation] = value; } 68 } 69 70 [ConfigurationProperty(ConfigurationStrings.BypassOnLocal, DefaultValue=(BypassOnLocalValues) BypassOnLocalValues.Unspecified)] 71 public BypassOnLocalValues BypassOnLocal 72 { 73 get { return (BypassOnLocalValues) this[this.bypassonlocal]; } 74 set { this[this.bypassonlocal] = value; } 75 } 76 77 [ConfigurationProperty(ConfigurationStrings.ProxyAddress)] 78 public Uri ProxyAddress 79 { 80 get { return (Uri) this[this.proxyaddress]; } 81 set { this[this.proxyaddress] = value; } 82 } 83 84 [ConfigurationProperty(ConfigurationStrings.UseSystemDefault, DefaultValue=(UseSystemDefaultValues) UseSystemDefaultValues.Unspecified)] 85 public UseSystemDefaultValues UseSystemDefault 86 { 87 get { return (UseSystemDefaultValues)this[this.usesystemdefault]; } 88 set { this[this.usesystemdefault] = value; } 89 } 90 91 ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); 92 93 readonly ConfigurationProperty autoDetect = 94 new ConfigurationProperty(ConfigurationStrings.AutoDetect, 95 typeof(AutoDetectValues), 96 AutoDetectValues.Unspecified, 97 new EnumConverter(typeof(AutoDetectValues)), 98 null, 99 ConfigurationPropertyOptions.None); 100 101 readonly ConfigurationProperty scriptLocation = 102 new ConfigurationProperty(ConfigurationStrings.ScriptLocation, 103 typeof(Uri), 104 null, 105 new UriTypeConverter(UriKind.Absolute), 106 null, 107 ConfigurationPropertyOptions.None); 108 109 // Supply a type converter, even though it's a plain type converter, to get around ConfigurationProperty's internal 110 // Enum conversion routine. The internal one is case-sensitive, we want this to be case-insensitive. 111 readonly ConfigurationProperty bypassonlocal = 112 new ConfigurationProperty(ConfigurationStrings.BypassOnLocal, 113 typeof(BypassOnLocalValues), 114 BypassOnLocalValues.Unspecified, 115 new EnumConverter(typeof(BypassOnLocalValues)), 116 null, 117 ConfigurationPropertyOptions.None); 118 119 readonly ConfigurationProperty proxyaddress = 120 new ConfigurationProperty(ConfigurationStrings.ProxyAddress, 121 typeof(Uri), 122 null, 123 new UriTypeConverter(UriKind.Absolute), 124 null, 125 ConfigurationPropertyOptions.None); 126 127 readonly ConfigurationProperty usesystemdefault = 128 new ConfigurationProperty(ConfigurationStrings.UseSystemDefault, 129 typeof(UseSystemDefaultValues), 130 UseSystemDefaultValues.Unspecified, 131 new EnumConverter(typeof(UseSystemDefaultValues)), 132 null, 133 ConfigurationPropertyOptions.None); 134 } 135 } 136 137