/// <summary> /// The main method /// </summary> /// <param name="args">Command line arguments. These arguments are expected to be created by <see cref="PackageSmartDetector.Execute"/>.</param> /// <returns>The exit code; 0 if the task successfully executed; otherwise, 1</returns> private static int Main(string[] args) { try { var packagePath = args[0]; var packageName = args[1]; SmartDetectorPackage package = SmartDetectorPackage.CreateFromFolder(packagePath); package.SaveToFile(Path.Combine(packagePath, packageName)); return(0); } catch (InvalidSmartDetectorPackageException exception) { Console.Write(exception.Message); return(1); } catch (IOException ioe) { Console.Write($"Failed to create Smart Detector Package - failed creating the package file: {ioe.Message}"); return(1); } catch (SecurityException securityException) { Console.Write($"Failed to create Smart Detector Package - failed creating the package file: {securityException.Message}"); return(1); } catch (Exception exception) { Console.Write(exception.Message); return(1); } }
/// <summary> /// Executes PackageSmartDetector task. /// </summary> /// <returns>True if the task successfully executed; otherwise, False.</returns> public override bool Execute() { try { SmartDetectorPackage package = SmartDetectorPackage.CreateFromFolder(this.PackagePath); package.SaveToFile(Path.Combine(this.PackagePath, this.PackageName)); } catch (InvalidSmartDetectorPackageException exception) { Log.LogError(exception.Message); return(false); } catch (IOException ioe) { Log.LogError($"Failed to create Smart Detector Package - failed creating the package file: {ioe.Message}"); return(false); } catch (SecurityException securityException) { Log.LogError($"Failed to create Smart Detector Package - failed creating the package file: {securityException.Message}"); return(false); } return(true); }