示例#1
0
        public static void That(bool condition, [NotNull] string message)
        {
            Requires.NotNullOrWhitespace(message, nameof(message));

            if (!condition)
            {
                throw new InvalidOperationException(message);
            }
        }
示例#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;
        }
示例#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}");
 }