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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ConnectionManagementElement.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 ConnectionManagementElement : ConfigurationElement
  23.     {
  24.         public ConnectionManagementElement()
  25.         {
  26.             this.properties.Add(this.address);
  27.             this.properties.Add(this.maxconnection);
  28.         }
  29.        
  30.         public ConnectionManagementElement(string address, int maxConnection) : this()
  31.         {
  32.             this.Address = address;
  33.             this.MaxConnection = maxConnection;
  34.         }
  35.        
  36.         protected override ConfigurationPropertyCollection Properties {
  37.             get { return this.properties; }
  38.         }
  39.        
  40.         [ConfigurationProperty(ConfigurationStrings.Address, IsRequired = true, IsKey = true)]
  41.         public string Address {
  42.             get { return (string)this[this.address]; }
  43.             set { this[this.address] = value; }
  44.         }
  45.        
  46.         [ConfigurationProperty(ConfigurationStrings.MaxConnection, IsRequired = true, DefaultValue = (int)1)]
  47.         public int MaxConnection {
  48.             get { return (int)this[this.maxconnection]; }
  49.             set { this[this.maxconnection] = value; }
  50.         }
  51.        
  52.         internal string Key {
  53.             get { return this.Address; }
  54.         }
  55.        
  56.         ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection();
  57.        
  58.         readonly ConfigurationProperty address = new ConfigurationProperty(ConfigurationStrings.Address, typeof(string), null, ConfigurationPropertyOptions.IsKey);
  59.        
  60.         readonly ConfigurationProperty maxconnection = new ConfigurationProperty(ConfigurationStrings.MaxConnection, typeof(int), 1, ConfigurationPropertyOptions.None);
  61.        
  62.     }
  63. }

Developer Fusion