/// <summary> /// Checks if the version of the SOLIDWORKS is newer or equal to the specified parameters /// </summary> /// <param name="app">Current SOLIDWORKS application</param> /// <param name="version">Target minimum supported version of SOLIDWORKS</param> /// <param name="servicePack">Target minimum service pack version or null to ignore</param> /// <param name="servicePackRev">Target minimum revision of service pack version or null to ignore</param> /// <returns>True of version of the SOLIDWORKS is the same or newer</returns> public static bool IsVersionNewerOrEqual(this ISldWorks app, SwVersion_e version, int?servicePack = null, int?servicePackRev = null) { if (!servicePack.HasValue && servicePackRev.HasValue) { throw new ArgumentException($"{nameof(servicePack)} must be specified when {nameof(servicePackRev)} is specified"); } int curSp; int curSpRev; var curVers = GetVersion(app, out curSp, out curSpRev); if (curVers >= version) { if (servicePack.HasValue && curVers == version) { if (curSp >= servicePack.Value) { if (servicePackRev.HasValue) { return(curSpRev >= servicePackRev.Value); } else { return(true); } } } else { return(true); } } return(false); }
/// <summary> /// Starts new application /// </summary> /// <param name="vers">Version or 0 for the latest</param> /// <param name="state">State of the application</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Created application</returns> public static ISwApplication Create(SwVersion_e vers = 0, ApplicationState_e state = ApplicationState_e.Default, CancellationToken?cancellationToken = null) { var app = PreCreate(); app.Version = vers; app.State = state; var token = CancellationToken.None; if (cancellationToken.HasValue) { token = cancellationToken.Value; } app.Commit(token); return(app); }
public static ISwVersion CreateVersion(SwVersion_e vers) => new SwVersion(vers);
public static bool IsVersionNewerOrEqual(this SwApplication app, SwVersion_e version, int?servicePack = null, int?servicePackRev = null) { return(app.Application.IsVersionNewerOrEqual(version, servicePack, servicePackRev)); }
internal SwVersion(SwVersion_e major) { Major = major; }
internal SwApplicationStarter(ApplicationState_e state, SwVersion_e version) { m_State = state; m_Version = version; }
public SwAppVersionInfo(SwVersion_e vers) : base(GetVersionDisplayName(vers), vers.ToString()) { Version = vers; }
private static string GetVersionDisplayName(SwVersion_e vers) => $"SOLIDWORKS {vers.ToString().Substring("Sw".Length)}";