Есть ли у кого-нибудь код c #для использования betfair API?

Я создаю приложение c #для Windows, чтобы отображать текущие курсы спортивного рынка, используя веб-сервис обмена betfair, я использовал

getmarketpricescompressed()

метод, который возвращает строку цены, которая выглядит следующим образом:

106093239~GBP~ACTIVE~0~1~~true~5.0~1343114432333~~N:7337~1~6992.56~2.16~~~false~~~~|2.16~1036.19~L~1~2.14~97.18~L~2~2.12~5.0~L~3~|2.18~467.36~B~1~2.2~34.12~B~2~2.22~162.03~B~3~:414464~2~102181.96~1.86~~~false~~~~|1.85~2900.33~L~1~1.84~1831.59~L~2~1.83~1593.73~L~3~|1.86~58.83~B~1~1.87~1171.77~B~2~1.88~169.15~B~3~

я не знаю, как правильно распаковать эту строку, пока я использую этот код:

GetMarketPricesCompressedReq price_req1 = new GetMarketPricesCompressedReq();
            price_req1.header = header2;
            price_req1.marketId = marketid_temp;
            price_req1.currencyCode = "GBP";
            GetMarketPricesCompressedResp price_resp = new GetMarketPricesCompressedResp();
            price_resp = bfg2.getMarketPricesCompressed(price_req1);
            //MessageBox.Show(price_resp.errorCode.ToString());
            //richTextBox1.Text = "";
            //richTextBox1.Text = price_resp.marketPrices;
            string prices = price_resp.marketPrices;
            richTextBox1.Text = price_resp.marketPrices;
            string[] ab1 = prices.Split('|');
            string[] temp = ab1[1].Split('~');
            textBox3.Text = temp[0];
            textBox4.Text = temp[4];
            textBox5.Text = temp[8];
            temp = ab1[2].Split('~');
            textBox6.Text = temp[0];
            textBox7.Text = temp[4];
            textBox8.Text = temp[8];
            temp = ab1[3].Split('~');
            textBox9.Text = temp[0];
            textBox10.Text = temp[4];
            textBox11.Text = temp[8];
            temp = ab1[4].Split('~');
            textBox12.Text = temp[0];
            textBox13.Text = temp[4];
            textBox14.Text = temp[8];
            if (ab1.Length >5)
            {
                temp = ab1[5].Split('~');
                textBox15.Text = temp[0];
                textBox16.Text = temp[4];
                textBox17.Text = temp[8];
                temp = ab1[6].Split('~');
                textBox18.Text = temp[0];
                textBox19.Text = temp[4];
                textBox20.Text = temp[8];
            }

Он отлично работает для нескольких совпадений, но я наблюдал изменения строки для нескольких других совпадений, и поэтому он генерирует исключения, Может ли кто-нибудь помочь мне с правильным кодом для распаковки этой строки, я погуглил и нашел код vb, который был не очень полезен,

и кстати, я хочу упорядочить данные примерно так:

enter image description here

6
задан Samy S.Rathore 24 July 2012 в 07:21
поделиться