1 //------------------------------------------------------------------------------
\r
3 // System.OperatingSystem.cs
\r
5 // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved
\r
7 // Author: Jim Richardson, develop@wtfo-guru.com
\r
8 // Created: Saturday, August 11, 2001
\r
10 //------------------------------------------------------------------------------
\r
17 /// Class representing a specific operating system version for a specific platform
\r
19 public sealed class OperatingSystem : ICloneable
\r
21 private System.PlatformID itsPlatform;
\r
22 private Version itsVersion;
\r
24 public OperatingSystem(PlatformID platform, Version version)
\r
28 throw new ArgumentNullException();
\r
31 itsPlatform = platform;
\r
32 itsVersion = version;
\r
36 /// Get the PlatformID
\r
38 public PlatformID Platform
\r
47 /// Gets the version object
\r
49 public Version Version
\r
58 /// Return a clone of this object
\r
60 public object Clone()
\r
62 return new OperatingSystem(itsPlatform, itsVersion);
\r
66 /// Return true if obj equals this object
\r
68 public override bool Equals(object obj)
\r
70 //Check for null and compare run-time types.
\r
71 if (obj == null || GetType() != obj.GetType()) return false;
\r
72 OperatingSystem os = (OperatingSystem)obj;
\r
73 return (itsPlatform == os.itsPlatform) &&
\r
74 (os.itsVersion.Equals(itsVersion));
\r
78 /// Return hash code
\r
80 public override int GetHashCode()
\r
81 { // this leave us enuf for 256 unique platforms which should suffice for a good while
\r
82 return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8;
\r
86 /// Return a string reprentation of this instance
\r
88 public override string ToString()
\r
94 case System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;
\r
95 case System.PlatformID.Win32S: str = "Microsoft Win32S"; break;
\r
96 case System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;
\r
97 case System.PlatformID.Linux: str = "Linux"; break;
\r
98 default: str = "<unknown>"; break;
\r
101 return str + " " + itsVersion.ToString();
\r