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
20 public sealed class OperatingSystem : ICloneable
\r
22 private System.PlatformID itsPlatform;
\r
23 private Version itsVersion;
\r
25 public OperatingSystem(PlatformID platform, Version version)
\r
29 throw new ArgumentNullException();
\r
32 itsPlatform = platform;
\r
33 itsVersion = version;
\r
37 /// Get the PlatformID
\r
39 public PlatformID Platform
\r
48 /// Gets the version object
\r
50 public Version Version
\r
59 /// Return a clone of this object
\r
61 public object Clone()
\r
63 return new OperatingSystem(itsPlatform, itsVersion);
\r
67 /// Return true if obj equals this object
\r
69 public override bool Equals(object obj)
\r
71 //Check for null and compare run-time types.
\r
72 if (obj == null || GetType() != obj.GetType()) return false;
\r
73 OperatingSystem os = (OperatingSystem)obj;
\r
74 return (itsPlatform == os.itsPlatform) &&
\r
75 (os.itsVersion.Equals(itsVersion));
\r
79 /// Return hash code
\r
81 public override int GetHashCode()
\r
82 { // this leave us enuf for 256 unique platforms which should suffice for a good while
\r
83 return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8;
\r
87 /// Return a string reprentation of this instance
\r
89 public override string ToString()
\r
95 case System.PlatformID.Win32NT: str = "Microsoft Windows NT"; break;
\r
96 case System.PlatformID.Win32S: str = "Microsoft Win32S"; break;
\r
97 case System.PlatformID.Win32Windows: str = "Microsoft Windows 98"; break;
\r
98 case System.PlatformID.Unix: str = "Unix"; break;
\r
99 default: str = Locale.GetText ("<unknown>"); break;
\r
102 return str + " " + itsVersion.ToString();
\r