//------------------------------------------------------------------------------ // // System.Environment.cs // // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved // // Author: Jim Richardson, develop@wtfo-guru.com // Created: Saturday, August 11, 2001 // //------------------------------------------------------------------------------ using System; namespace Mono.System { // this seemed like a logical place to put this enumeration public enum PlatformID { // TODO: determine what definitions to incorporate // possibilities are quite varied minPlatform, i386Linux = minPlatform, i686Linux, maxPlatform } /// /// Class representing a specific operating system version for a specific platform /// public sealed class OperatingSystem : ICloneable { private PlatformID itsPlatform; private Version itsVersion; public OperatingSystem(PlatformID platform, Version version) { if(version == null) { throw new ArgumentNullException(); } // the doc doesn't say this, but I would //if(platform < minPlatform || platform >= maxPlatform) //{ // throw new ArgumentOutOfRangeException(); // TODO: find out if C# has assertion mechanism // isn't learning new languages fun? :) //} itsPlatform = platform; itsVersion = version; } /// /// Get the PlatformID /// public PlatformID Platform { get { return itsPlatform; } } /// /// Gets the version object /// public Version Version { get { return itsVersion; } } /// /// Return a clone of this object /// public object Clone() { return new OperatingSystem(itsPlatform, itsVersion); } /// /// Return true if obj equals this object /// public override bool Equals(object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) return false; OperatingSystem os = (OperatingSystem)obj; return (itsPlatform == os.itsPlatform) && (os.itsVersion.Equals(itsVersion)); } /// /// Return hash code /// public override int GetHashCode() { return ((int)itsPlatform << 24) | itsVersion.GetHashCode() >> 8; } /// /// Return a string reprentation of this instance /// public override string ToString() { return itsPlatform.ToString() + ", " + itsVersion.ToString(); } } }