The Labs \ Source Viewer \ SSCLI \ System.Net.NetworkInformation \ IPAddressCollection

  1. //------------------------------------------------------------------------------
  2. // <copyright file="IPAddressCollection.cs" company="Microsoft">
  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. using System.Collections.Generic;
  16. using System.Collections.ObjectModel;
  17. namespace System.Net.NetworkInformation
  18. {
  19.     public class IPAddressCollection : ICollection<IPAddress>
  20.     {
  21.         Collection<IPAddress> addresses = new Collection<IPAddress>();
  22.        
  23.         protected internal IPAddressCollection()
  24.         {
  25.         }
  26.        
  27.         /// <include file='doc\HttpListenerPrefixCollection.uex' path='docs/doc[@for="HttpListenerPrefixCollection.CopyTo"]/*' />
  28.         public virtual void CopyTo(IPAddress[] array, int offset)
  29.         {
  30.             addresses.CopyTo(array, offset);
  31.         }
  32.        
  33.        
  34.         /// <include file='doc\HttpListenerPrefixCollection.uex' path='docs/doc[@for="HttpListenerPrefixCollection.Count"]/*' />
  35.         public virtual int Count {
  36.             get { return addresses.Count; }
  37.         }
  38.        
  39.         public virtual bool IsReadOnly {
  40.             get { return true; }
  41.         }
  42.        
  43.         public virtual void Add(IPAddress address)
  44.         {
  45.             throw new NotSupportedException(SR.GetString(SR.net_collection_readonly));
  46.         }
  47.        
  48.        
  49.         internal void InternalAdd(IPAddress address)
  50.         {
  51.             addresses.Add(address);
  52.         }
  53.        
  54.        
  55.         /// <include file='doc\HttpListenerPrefixCollection.uex' path='docs/doc[@for="HttpListenerPrefixCollection.Contains"]/*' />
  56.         public virtual bool Contains(IPAddress address)
  57.         {
  58.             return addresses.Contains(address);
  59.         }
  60.        
  61.        
  62.         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  63.         {
  64.             return null;
  65.         }
  66.        
  67.         public virtual IEnumerator<IPAddress> GetEnumerator()
  68.         {
  69.             return (IEnumerator<IPAddress>)addresses.GetEnumerator();
  70.         }
  71.        
  72.        
  73.         public virtual IPAddress this[int index]
  74.         {
  75.             get { return (IPAddress)addresses[index]; }
  76.         }
  77.        
  78.        
  79.         /// <include file='doc\HttpListenerPrefixCollection.uex' path='docs/doc[@for="HttpListenerPrefixCollection.Remove"]/*' />
  80.         public virtual bool Remove(IPAddress address)
  81.         {
  82.             throw new NotSupportedException(SR.GetString(SR.net_collection_readonly));
  83.         }
  84.        
  85.         /// <include file='doc\HttpListenerPrefixCollection.uex' path='docs/doc[@for="HttpListenerPrefixCollection.Clear"]/*' />
  86.         public virtual void Clear()
  87.         {
  88.             throw new NotSupportedException(SR.GetString(SR.net_collection_readonly));
  89.         }
  90.     }
  91. }

Developer Fusion