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
13 using System.Globalization;
\r
18 /// Class representing a specific operating system version for a specific platform
\r
21 public sealed class OperatingSystem : ICloneable
\r
23 private System.PlatformID itsPlatform;
\r
24 private Version itsVersion;
\r
26 public OperatingSystem(PlatformID platform, Version version)
\r
30 throw new ArgumentNullException();
\r
33 itsPlatform = platform;
\r
34 itsVersion = version;
\r
38 /// Get the PlatformID
\r
40 public PlatformID Platform
\r
49 /// Gets the version object
\r
51 public Version Version
\r
60 /// Return a clone of this object
\r
62 public object Clone()
\r
64 return new OperatingSystem(itsPlatform, itsVersion);
\r
68 /// Return true if obj equals this object
\r
70 public override bool Equals(object obj)
\r
72 //Check for null and compare run-time types.
\r
73 if (obj == null || GetType() != obj.GetType()) return false;
\r
74 OperatingSystem os = (OperatingSystem)obj;
\r
75 return (itsPlatform == os.itsPlatform) &&
\r
76 (os.itsVersion.Equals(itsVersion));
\r
80 /// Return hash code
\r
82 public override int GetHashCode()
\r
83 { // this leave us enuf for 256 unique platforms which should suffice for a good while
\r
84 return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8;
\r
88 /// Return a string reprentation of this instance
\r
90 public override string ToString()
\r
96 case System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;
\r
97 case System.PlatformID.Win32S: str = "Microsoft Win32S"; break;
\r
98 case System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;
\r
99 case System.PlatformID.Unix: str = "Unix"; break;
\r
100 default: str = Locale.GetText ("<unknown>"); break;
\r
103 return str + " " + itsVersion.ToString();
\r