コード例 #1
0
ファイル: t1974.cs プロジェクト: iPeterPan/XingAPI
        public static XQt1974OutBlock1[] ListFromQuery(XQt1974 query)
        {
            int count = query.GetBlockCount(XQt1974OutBlock1.BlockName);
            List <XQt1974OutBlock1> list = new List <XQt1974OutBlock1>();

            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                return(list.ToArray());
            }
            for (int i = 0; i < count; i++)
            {
                XQt1974OutBlock1 block = new XQt1974OutBlock1();
                block.IsValidData   = true;
                block.InvalidReason = "";
                try
                {
                    block.shcode  = query.GetFieldData(block.GetBlockName(), "shcode", i).TrimEnd('?');                  // char 6
                    block.hname   = query.GetFieldData(block.GetBlockName(), "hname", i).TrimEnd('?');                   // char 40
                    block.cpgubun = query.GetFieldData(block.GetBlockName(), "cpgubun", i).TrimEnd('?');                 // char 2
                    block.price   = query.GetFieldData(block.GetBlockName(), "price", i).ParseLong("price");             // long 8
                    block.sign    = query.GetFieldData(block.GetBlockName(), "sign", i).FirstOrDefault();                // char 1
                    block.change  = query.GetFieldData(block.GetBlockName(), "change", i).ParseLong("change");           // long 8
                    block.diff    = query.GetFieldData(block.GetBlockName(), "diff", i).ParseFloat("diff");              // float 6.2
                    block.volume  = query.GetFieldData(block.GetBlockName(), "volume", i).ParseFloat("volume");          // float 12
                } catch (InvalidDataFormatException e) {
                    block.IsValidData   = false;
                    block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
                }
                list.Add(block);
            }
            return(list.ToArray());
        }
コード例 #2
0
ファイル: t1974.cs プロジェクト: iPeterPan/XingAPI
        public static XQt1974OutBlock FromQuery(XQt1974 query)
        {
            XQt1974OutBlock block = new XQt1974OutBlock();

            block.IsValidData   = true;
            block.InvalidReason = "";
            if (query.QueryResult != null && query.QueryResult.IsSystemError == true)
            {
                block.IsValidData   = false;
                block.InvalidReason = query.ReceiveMessage;
                return(block);
            }
            try
            {
                block.cnt = query.GetFieldData(block.GetBlockName(), "cnt", 0).ParseLong("cnt");                 // long 4
            } catch (InvalidDataFormatException e) {
                block.IsValidData   = false;
                block.InvalidReason = $"FieldName == {e.DataFieldName}, FieldData == \"{e.DataValue}\"";
            }
            return(block);
        }