Merge pull request #2869 from BrzVlad/feature-mod-union-opt
[mono.git] / mcs / class / System / System.Net / IPHostEntry.cs
1 // System.Net.IPHostEntry.cs
2 //
3 // Author: Mads Pultz (mpultz@diku.dk)
4 //
5 // (C) Mads Pultz, 2001
6
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 // 
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 // 
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 //
27
28 using System;
29
30 namespace System.Net {
31         
32         public class IPHostEntry {
33                 private IPAddress[] addressList;
34                 private String[] aliases;
35                 private String hostName;
36                 
37                 public IPHostEntry() {
38                 }
39                 
40                 public IPAddress[] AddressList {
41                         get { return addressList; }
42                         set { addressList = value; }
43                 }
44                 
45                 public string[] Aliases {
46                         get { return aliases; }
47                         set { aliases = value; }
48                 }
49                 
50                 public string HostName {
51                         get { return hostName; }
52                         set { hostName = value; }
53                 }
54                 
55 /* According to the .NET Framework SDK Documentation (beta 2) the following
56    methods from Object are not overrided. I implemented them before realizing
57    this but I leave the implementation here if needed in the future.
58    
59                 public override string ToString() {
60                         string res = hostName;
61                         if (addressList != null && addressList.Length > 0)
62                                 res += " [" + addressList[0] + "]";
63                         return res;
64                 }
65                 
66                 public override bool Equals(object obj) {
67                         if (obj is IPHostEntry) {
68                                 IPHostEntry h = (IPHostEntry)obj;
69                                 return hostName.Equals(h.HostName) && aliases.Equals(h.Aliases) &&
70                                         addressList.Equals(h.AddressList);
71                         }
72                         else
73                           return false;
74                 }
75                 
76                 public override int GetHashCode() {
77                         return hostName.GetHashCode();
78                 }
79                 
80                 protected new object MemberwiseClone() {
81                         IPHostEntry res = new IPHostEntry();
82                         res.AddressList = new IPAddress[addressList.Length];
83                         Array.Copy(addressList, res.AddressList, addressList.Length);
84                         res.Aliases = new String[aliases.Length];
85                         Array.Copy(aliases, res.Aliases, aliases.Length);
86                         res.HostName = hostName;
87                         return res;
88                 }
89 */
90         }
91 }
92