Parse() public static method

public static Parse ( string txtFromServer ) : string
txtFromServer string
return string
コード例 #1
0
ファイル: DictTest.cs プロジェクト: Centny/cswf
 public void ParseTest()
 {
     var dict = new Dict();
     dict["ival"] = 1;
     dict["ival_a"] = new int[] { 1, 2, 3 };
     dict["ival_l"] = new List<int> { 10, 20, 30 };
     //
     dict["fval"] = 1.2;
     dict["fval_a"] = new float[] { 1, 2, 3 };
     dict["fval_l"] = new List<float> { 10, 20, 30 };
     //
     dict["sval"] = "val";
     dict["sval_a"] = new string[] { "a", "b", "c" };
     dict["sval_l"] = new List<string> { "a1", "b1", "c1" };
     //
     dict["oval"] = Util.dict("a", "x1");
     dict["oval_a"] = new IDictionary<string, object>[] {
         Util.dict("a", "x2"),
         Util.dict("a", "x3"),
         Util.dict("a", "x4"),
     };
     dict["oval_l"] = new List<IDictionary<string, object>> {
         Util.dict("a", "x2"),
         Util.dict("a", "x3"),
         Util.dict("a", "x4"),
     };
     var res = (ClsA)dict.Parse(typeof(ClsA));
     //
     Assert.AreEqual(1, res.IVal);
     Assert.AreEqual(3, res.IValA.Length);
     Assert.AreEqual(1, res.IValA[0]);
     Assert.AreEqual(3, res.IValL.Count);
     Assert.AreEqual(10, res.IValL[0]);
     //
     Assert.AreEqual(1.2f, res.FVal);
     Assert.AreEqual(3, res.FValA.Length);
     Assert.AreEqual(3, res.FValL.Count);
     //
     Assert.AreEqual("val", res.SVal);
     Assert.AreEqual(3, res.SValA.Length);
     Assert.AreEqual(3, res.SValL.Count);
     //
     Assert.AreEqual("x1", res.OVal.A);
     Assert.AreEqual(3, res.OValA.Length);
     Assert.AreEqual(3, res.OValL.Count);
 }