public static bool IsOSAtLeast(OSVersion reqMinOS) { uint major = 0, minor = 0; switch (reqMinOS) { case OSVersion.WIN_2000: major = 5; minor = 0; break; case OSVersion.WIN_XP: major = 5; minor = 1; break; case OSVersion.WIN_SERVER_2003: major = 5; minor = 2; break; case OSVersion.WIN_VISTA: major = 6; minor = 0; break; case OSVersion.WIN_7: major = 6; minor = 1; break; default: System.Diagnostics.Debug.Assert(false); break; } return ((Environment.OSVersion.Version.Major << 16 | Environment.OSVersion.Version.Minor << 8) >= (major << 16 | minor << 8)); }
static OS() { switch (Environment.OSVersion.Platform) { case PlatformID.Win32Windows: if (Environment.OSVersion.Version.Major == 4) { if (Environment.OSVersion.Version.Minor < 90) { if (Environment.OSVersion.Version.Minor >= 10) { Version = OSVersion.Win98; } break; } Version = OSVersion.WinME; } break; case PlatformID.Win32NT: if (Environment.OSVersion.Version.Major < 6) { if (Environment.OSVersion.Version.Major >= 5) { Version = (Environment.OSVersion.Version.Minor > 0) ? OSVersion.WinXP : OSVersion.Win2k; } else if (Environment.OSVersion.Version.Major >= 4) { Version = OSVersion.WinNT; } break; } Version = (Environment.OSVersion.Version.Minor > 0) ? OSVersion.Win7 : OSVersion.WinVista; break; } }
//----------------------------------------------------------------------------- // Static methods public static OSVersionInfo GetOSVersionInfo( OSVersion v ) { switch ( v ) { case OSVersion.Win32s : return Win32s ; case OSVersion.Win95 : return Win95 ; case OSVersion.Win98 : return Win98 ; case OSVersion.WinME : return WinME ; case OSVersion.WinNT351 : return WinNT351 ; case OSVersion.WinNT4 : return WinNT4 ; case OSVersion.Win2000 : return Win2000 ; case OSVersion.WinXP : return WinXP ; case OSVersion.Win2003 : return Win2003 ; case OSVersion.WinCE : return WinCE ; default: throw new InvalidOperationException(); } }
private bool CompareOSVersion(OSVersion osVersion) { OSVersion filterOSVersion; if (Enum.TryParse(Value, out filterOSVersion)) { switch (Comparison) { case FilterComparison.Equals: case FilterComparison.NotEquals: return osVersion == filterOSVersion; case FilterComparison.GreaterOrEqual: return osVersion >= filterOSVersion; case FilterComparison.GreaterThan: return osVersion > filterOSVersion; case FilterComparison.LessOrEqual: return osVersion <= filterOSVersion; case FilterComparison.LessThan: return osVersion < filterOSVersion; default: throw new Exception("Invalid comparison for OSVersion column: " + Comparison); } } else { // Invalid value for OSVersion column return false; } }
/// <summary> /// Initialize adapter. /// </summary> /// <param name="testSite">The test site instance associated with the current adapter.</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); PccrtpBothRoleCapture.Initialize(testSite); this.Site.DefaultProtocolDocShortName = "MS-PCCRTP"; this.sutOsVersion = (OSVersion)Enum.Parse( typeof(OSVersion), this.Site.Properties["Environment.DistributedSUT.OSVersion"].ToString(), true); this.isIpv4 = bool.Parse(Site.Properties["PCCRTP.Protocol.Address.isIPv4"]); this.listenPort = int.Parse(Site.Properties["Environment.ContentServer.HTTP.Port"]); if (this.isIpv4) { this.pccrtpServerStack = new PccrtpServer(this.listenPort, IPAddressType.IPv4, new Logger(testSite)); } else { this.pccrtpServerStack = new PccrtpServer(this.listenPort, IPAddressType.IPv6, new Logger(testSite)); } this.pccrtpServerStack.StartServer(); }
/// <summary> /// Initialize adapter. /// </summary> /// <param name="testSite">The test site instance associated with the current adapter.</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); PccrtpBothRoleCapture.Initialize(testSite); this.pccrtpClientStack = new PccrtpClient(new Logger(testSite)); this.Site.DefaultProtocolDocShortName = "MS-PCCRTP"; SutOsVersion = (OSVersion)Enum.Parse( typeof(OSVersion), this.GetProperty("Environment.ContentServer.OSVersion"), true); }