?????????????????????????????????????????????鼮???????濪???????????????????????????????磬?????о????????????????н?????????????????????????????????????е???????????ζ???????????????????????????????????????TDD??????????????????????????????????????????????????????????????????????о????????θ?????????????????????????????′????????????????????????????????????ɡ??????????Щ????????л??????????????

????MyDriver???????

???????????????????????????????C#??Java????????????????????????????λ??????????????????????Χ??C#????????????????Java?????C#??????????????????????£????Щ???????????????????

??????????????????MyDriver???????????????????????????????????????????????£???????????????????????????????????????????κδ??????????MyClient?????????????

????MyDriver????????????????MyDriverClient?????м???????????

?????? MyDriverClient(string uri)?????????????????MyDriverClient??????????uri?????????????????????????衣

?????? void Connect()?????????????????????????к?????????

?????? void AddQuery(int queryId)??????????????????????????queryId????????queryId??ε??????????????????????

?????? void RemoveQuery(int queryId)??????????????????????????queryId??????????????????????????????κ????顣

?????? void Close()????????????????????

?????? MyData Receive()?????????????????????????????????????????????????????????????????null??

????????Connect??AddQuery??RemoveQuery??Receive???????????????????????????п???????MyDriverException????Щ?????????????????MyDriverClient?????????????????????????????????????Close???????????

????MyData????????Σ?int?????QueryID????????????Value??????????????????????????????Value?????????????????????????????????????????????????????????????????????RemoveQuery????????id?????????????????????????????????????????id?й?????????????????????Receive??????????????id?й??MyData??????????????????????????????????

?????????AddQuery??????????id???????????????????????????{ QueryID?? id?? Value?? "begin" }??????MyData???????????????Ч?????????????????????ò???????????

??????Program???????п???е?Main?????????????????????????Щ??????

static voidMain(string[] args)
{vardriver =newMyDriverClient("jeffz://server:12345");try{
        driver.Connect();
        driver.AddQuery(1);
        driver.AddQuery(2);
        driver.AddQuery(3);
    }catch{
        driver.Close();Console.WriteLine("Error occurred when connect or add query.");Environment.Exit(1);
    }newThread(() => ReceiveData(driver)).Start();
}private static voidReceiveData(MyDriverClientdriver)
{try{while(true)
        {vardata = driver.Receive();if(data ==null)
            {Console.WriteLine("Closed");break;
            }else{Console.WriteLine(data);
            }
        }
    }catch(MyDriverException)
    {
        driver.Close();Console.WriteLine("Error occurred when receive data.");
    }
}