コード例 #1
0
 public AppVersionInfo ParseVersion(string version)
 {
     if (string.IsNullOrEmpty(version))
     {
         var installedVers = SwApplication.GetInstalledVersions();
         if (installedVers.Any())
         {
             return(new SwAppVersionInfo(installedVers.OrderBy(v => (int)v).First()));
         }
         else
         {
             throw new Exception("Failed to find installed version of the host application");
         }
     }
     else if (int.TryParse(version, out int rev))
     {
         var swVers = (SwVersion_e)Enum.Parse(typeof(SwVersion_e), $"Sw{rev}");
         return(new SwAppVersionInfo(swVers));
     }
     else if (version.StartsWith("solidworks", StringComparison.CurrentCultureIgnoreCase))
     {
         var swVers = (SwVersion_e)Enum.Parse(typeof(SwVersion_e), $"Sw{version.Substring("solidworks".Length).Trim()}");
         return(new SwAppVersionInfo(swVers));
     }
     else
     {
         var swVers = (SwVersion_e)Enum.Parse(typeof(SwVersion_e), version);
         return(new SwAppVersionInfo(swVers));
     }
 }
コード例 #2
0
 public IEnumerable <AppVersionInfo> GetInstalledVersions()
 => SwApplication.GetInstalledVersions()
 .Select(x => new SwAppVersionInfo(x));