Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public MockSimpleProcess(SimpleProcessInfo info)
 {
     Info = info;
 }