Пример #1
0
        //This method fetches a specific subset of data.
        async Task <EOS_Table <T> > GetDataSubset(string lower_bound, int limit, T rowObject)
        {
            if (_metadata == null)
            {
                //_metadata = ((T)Activator.CreateInstance(typeof(T))).GetMetaData();
                _metadata = rowObject.GetMetaData();
            }
            string key_type = _metadata.key_type;
            var    content  = string.Empty;

            if (String.IsNullOrEmpty(lower_bound))
            {
                content = string.Format("{{\"scope\":\"{0}\", \"code\":\"{1}\", \"table\":\"{2}\", \"json\": true, \"limit\":{5}}}", _metadata.scope, _metadata.contract, _metadata.table, lower_bound, "", limit);
            }
            else
            {
                if (string.IsNullOrEmpty(key_type))
                {
                    content = string.Format("{{\"scope\":\"{0}\", \"code\":\"{1}\", \"table\":\"{2}\", \"json\": true, \"lower_bound\":\"{3}\", \"upper_bound\":\"{4}\", \"limit\":{5}}}", _metadata.scope, _metadata.contract, _metadata.table, lower_bound, "", limit);
                }
                else
                {
                    content = string.Format("{{\"scope\":\"{0}\", \"code\":\"{1}\", \"table\":\"{2}\", \"json\": true, \"lower_bound\":\"{3}\", \"upper_bound\":\"{4}\", \"limit\":{5}, \"key_type\":\"{6}\"}}", _metadata.scope, _metadata.contract, _metadata.table, lower_bound, "", limit, key_type);
                }
            }

            var responseString = await HttpUtility.GetValidatedAPIResponse(_uri, new StringContent(content));

            return(JsonConvert.DeserializeObject <EOS_Table <T> >(responseString));
        }
Пример #2
0
 public EOS_Table(Uri host, EOSTableMetadata metaData)
 {
     _uri      = new Uri(host, "v1/chain/get_table_rows");
     _metadata = metaData;
 }