/// <summary> /// Determines whether the assembly is executing on the specified operating system version with /// the specified service pack installed or any later version of windows. If not, an exception is thrown. /// </summary> /// <param name="osVersion">The minimum operating system version required.</param> /// <param name="servicePackVersion">The minimum service pack version required.</param> /// <exception cref="UnsupportedOperatingSystemException">The current operating system is of a version earlier /// than the specified <paramref name="osVersion"/> or the versions match but the operating system does not /// have at least the specified service pack version <paramref name="servicePackVersion"/> installed.</exception> public static void RequireAtLeast(OSVersionName osVersion, int servicePackVersion) { if (!IsAtLeast(osVersion, servicePackVersion)) { throw new UnsupportedOperatingSystemException(); } }
/// <summary> /// Determines whether the operating system is a server operating system of atleast the specified <paramref name="serverVersion"/> and /// <paramref name="serverServicePackVersion"/> and throws an <see cref="UnsupportedOperatingSystemException"/> otherwise. /// </summary> /// <param name="serverVersion">The server version.</param> /// <param name="serverServicePackVersion">The server service pack version.</param> public static void RequireServer(OSVersionName serverVersion, int serverServicePackVersion) { if (!IsServer || !IsAtLeast(serverVersion, serverServicePackVersion)) { throw new UnsupportedOperatingSystemException(); } }
/// <summary> /// Determines whether operating system is of the specified server version or later or if it is of the specified client /// version or later and throws <see cref="UnsupportedOperatingSystemException"/> otherwise. /// </summary> /// <param name="serverVersion">The minimum server version.</param> /// <param name="serverServicePackVersion">The minimum server service pack version (applies only if the version exactly matches the specified server version).</param> /// <param name="clientVersion">The minimum client version.</param> /// <param name="clientServicePackVersion">The minimum client service pack version (applies only if the version exactly matches the specified client version).</param> public static void RequireServerOrClientAtLeast(OSVersionName serverVersion, int serverServicePackVersion, OSVersionName clientVersion, int clientServicePackVersion) { if (IsServer && !IsAtLeast(serverVersion, serverServicePackVersion) || !IsServer && !IsAtLeast(clientVersion, clientServicePackVersion)) { throw new UnsupportedOperatingSystemException(); } }
/// <summary> /// Determines whether the assembly is executing on the specified operating system version with /// the specified service pack installed or any later version of windows. If not, an exception is thrown. /// </summary> /// <param name="osVersion">The minimum operating system version required.</param> /// <param name="servicePackVersion">The minimum service pack version required.</param> /// <exception cref="UnsupportedOperatingSystemException">The current operating system is of a version earlier /// than the specified <paramref name="osVersion"/> or the versions match but the operating system does not /// have at least the specified service pack version <paramref name="servicePackVersion"/> installed.</exception> public static void RequireAtLeast(OSVersionName osVersion, int servicePackVersion) { if (!IsAtLeast(osVersion, servicePackVersion)) throw new UnsupportedOperatingSystemException(); }
/// <summary> /// Determines whether the operating system is a server operating system of atleast the specified <paramref name="serverVersion"/> and /// <paramref name="serverServicePackVersion"/> and throws an <see cref="UnsupportedOperatingSystemException"/> otherwise. /// </summary> /// <param name="serverVersion">The server version.</param> /// <param name="serverServicePackVersion">The server service pack version.</param> public static void RequireServer(OSVersionName serverVersion, int serverServicePackVersion) { if (!IsServer || !IsAtLeast(serverVersion, serverServicePackVersion)) throw new UnsupportedOperatingSystemException(); }
/// <summary> /// Determines whether operating system is of the specified server version or later or if it is of the specified client /// version or later and throws <see cref="UnsupportedOperatingSystemException"/> otherwise. /// </summary> /// <param name="serverVersion">The minimum server version.</param> /// <param name="serverServicePackVersion">The minimum server service pack version (applies only if the version exactly matches the specified server version).</param> /// <param name="clientVersion">The minimum client version.</param> /// <param name="clientServicePackVersion">The minimum client service pack version (applies only if the version exactly matches the specified client version).</param> public static void RequireServerOrClientAtLeast(OSVersionName serverVersion, int serverServicePackVersion, OSVersionName clientVersion, int clientServicePackVersion) { if (IsServer && !IsAtLeast(serverVersion, serverServicePackVersion) || !IsServer && !IsAtLeast(clientVersion, clientServicePackVersion)) throw new UnsupportedOperatingSystemException(); }
/// <summary> /// Determines whether operating system is of the specified version or later, allowing specification of /// a minimum service pack that must be installed on the lowest version. /// </summary> /// <param name="version">The minimum required version.</param> /// <param name="servicePackVersion">The major version of the service pack that must be installed on the /// minimum required version to return <c>true</c>. This can be 0 to indicate that no service pack is required.</param> /// <returns> /// <c>true</c> if the operating system matches the specified <paramref name="version"/> with the specified service pack, or if the operating system is of a later version; otherwise, <c>false</c>. /// </returns> public static bool IsAtLeast(OSVersionName version, int servicePackVersion) { return OSVersionName == version && ServicePackVersion.Major >= servicePackVersion || OSVersionName > version; }
/// <summary> /// Determines whether the operating system is of the specified version or later. /// </summary> /// <param name="version">The lowest version for which to return <c>true</c>.</param> /// <returns> /// <c>true</c> if the operating system is of the specified <paramref name="version"/> or later; otherwise, <c>false</c>. /// </returns> public static bool IsAtLeast(OSVersionName version) { return OSVersionName >= version; }
/// <summary> /// Determines whether operating system is of the specified version or later, allowing specification of /// a minimum service pack that must be installed on the lowest version. /// </summary> /// <param name="version">The minimum required version.</param> /// <param name="servicePackVersion">The major version of the service pack that must be installed on the /// minimum required version to return <c>true</c>. This can be 0 to indicate that no service pack is required.</param> /// <returns> /// <c>true</c> if the operating system matches the specified <paramref name="version"/> with the specified service pack, or if the operating system is of a later version; otherwise, <c>false</c>. /// </returns> public static bool IsAtLeast(OSVersionName version, int servicePackVersion) { return(OSVersionName == version && ServicePackVersion.Major >= servicePackVersion || OSVersionName > version); }
/// <summary> /// Determines whether the operating system is of the specified version or later. /// </summary> /// <param name="version">The lowest version for which to return <c>true</c>.</param> /// <returns> /// <c>true</c> if the operating system is of the specified <paramref name="version"/> or later; otherwise, <c>false</c>. /// </returns> public static bool IsAtLeast(OSVersionName version) { return(OSVersionName >= version); }