Exemple #1
0
        private void CmdExecute(CmdString operateCmd)
        {
            if (operateCmd.Match(CmdStrings.StartMirror) ||
                operateCmd.Match(CmdStrings.ContinueMirror))
            {
                _mirror.Initialize(deviceSerialnumber, isHtc, path);
                _thread = new Thread(
                    o =>
                {
                    _mirror.Start(block, startedPos);
                });
                _thread.IsBackground = true;
                _thread.Start();
            }
            else if (operateCmd.Match(CmdStrings.StopMirror) ||
                     operateCmd.Match(CmdStrings.PauseMirror))
            {
                _thread.Abort();
                _isStop = true;
            }

            //返回当前状态
            if (_mirror.IsInitialized)
            {
                SendSate(operateCmd);
            }
        }
Exemple #2
0
        public void Run()
        {
            while (true)
            {
                var arg = Console.ReadLine();
                if (arg == null)//当正在镜像时,关闭客户端arg就会为空
                {
                    break;
                }

                Console.WriteLine("收到arg:" + arg);
                string    operateStr = ParseArgs(arg);
                CmdString operate    = new CmdString(operateStr);
                try
                {
                    CmdExecute(operate);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("{0}|{1}", CmdStrings.Exception, ex.Message);
                    throw ex;
                }

                if (_isStop)
                {
                    break;
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// 命令是不是cmd类型
 /// </summary>
 /// <param name="cmd"></param>
 /// <returns></returns>
 internal bool IsType(CmdString cmd)
 {
     if (_cmdString.StartsWith(cmd._cmdString, StringComparison.OrdinalIgnoreCase))
     {
         return(true);
     }
     return(false);
 }
Exemple #4
0
 /// <summary>
 ///命令字符串是否相匹配
 /// </summary>
 internal bool Match(CmdString cmd)
 {
     if (_cmdString.Equals(cmd._cmdString, StringComparison.OrdinalIgnoreCase))
     {
         return(true);
     }
     return(false);
 }
Exemple #5
0
        internal CmdString Substring(CmdString cmd)
        {
            string str = _cmdString.Substring(cmd.CmdAreaLength);

            return(new CmdString(str));
        }
Exemple #6
0
 /// <summary>
 /// 发送状态到调用端
 /// </summary>
 public void SendSate(CmdString cmd)
 {
     Console.WriteLine(string.Format("{0}", cmd));
 }