Ejemplo n.º 1
0
        public static void That(bool condition, [NotNull] string message)
        {
            Requires.NotNullOrWhitespace(message, nameof(message));

            if (!condition)
            {
                throw new InvalidOperationException(message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Initializes a new instance.
        /// </summary>
        /// <param name="fileName">The file name of the external executable.</param>
        /// <param name="commandLineArguments">The command line arguments that should be passed to the executable.</param>
        /// <param name="outputCallback">The callback that is invoked when an output is generated.</param>
        public ExternalProcess(string fileName, string commandLineArguments, Action <string> outputCallback = null)
        {
            Requires.NotNullOrWhitespace(fileName, nameof(fileName));
            Requires.NotNull(commandLineArguments, nameof(commandLineArguments));

            _process = new Process
            {
                EnableRaisingEvents = true,
                StartInfo           = new ProcessStartInfo(fileName, commandLineArguments)
                {
                    UseShellExecute        = false,
                    RedirectStandardError  = true,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    CreateNoWindow         = true
                }
            };

            _outputCallback = outputCallback;
        }
Ejemplo n.º 3
0
 /// <summary>
 ///   Initializes a new instance.
 /// </summary>
 /// <param name="extension">The extension of the generated file.</param>
 public TemporaryFile(string extension)
 {
     Requires.NotNullOrWhitespace(extension, nameof(extension));
     FilePath = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.{extension}");
 }