示例#1
0
        public static SimpleProcessInfo Create(string processName, string exePath, string exeArgs, bool validateFailThrows = false)
        {
            var simpleProcessInfo = new SimpleProcessInfo()
            {
                ProcessName = processName,
                ExePath     = exePath,
                ExeArgs     = exeArgs
            };

            if (validateFailThrows)
            {
                var success = Validate(simpleProcessInfo, out var message);
                if (!success)
                {
                    throw new ArgumentException(string.Format("bad create args: processName:{0}, exePath:{1}, exeArgs:{2}", processName, exePath, exeArgs));
                }
            }

            return(simpleProcessInfo);
        }
示例#2
0
        public static bool Validate(SimpleProcessInfo info, out string message)
        {
            if (info == null)
            {
                message = "info should not be null";
                return(false);
            }

            if (string.IsNullOrWhiteSpace(info.ProcessName))
            {
                message = "ProcessName should not be null or empty";
                return(false);
            }

            if (string.IsNullOrWhiteSpace(info.ExePath))
            {
                message = "ExePath should not be null or empty";
                return(false);
            }

            message = "OK";
            return(true);
        }
 public MockSimpleProcess(SimpleProcessInfo info)
 {
     Info = info;
 }