commander.cs

来自「P2PGrid.rar 从网上下载的一套C#源码」· CS 代码 · 共 54 行

CS
54
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace P2PGrid
{
    class Commander
    {

        private INetworkOperator netOperation;

        public Commander(INetworkOperator ino)
        {
            netOperation = ino;
        }

        public void Excute(string com)
        {

            string [] commands=com.Split(' ');
            int count = commands.Length;
            if (count > 0)
            {
                string first=commands[0].ToLower();
                if (first == "start"&&(count==2))
                {
                    netOperation.Start(int.Parse(commands[1]));
                }
                if (first == "connect" && (count==2||count==3) )
                {
                    if (count == 2)
                        netOperation.Connect("127.0.0.1", int.Parse(commands[1]));
                    else
                        netOperation.Connect(commands[1],int.Parse(commands[2]));
                }
                if (first == "close" && (count == 1))
                {
                    netOperation.CloseClient();
                }
                if (first == "get" && (count == 3))
                {
                    netOperation.Send(com);
                }
                if (first == "set" && (count == 4))
                {
                    netOperation.Send(com);
                }
            }
        }

       
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?