本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.ToObject方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.ToObject方法的具体用法?C# JArray.ToObject怎么用?C# JArray.ToObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.ToObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTraceComplete
public void OnTraceComplete(JArray myArray)
{
// HACK: not sure why we have to explicitly cast the argument from a JArray, I thought Signalr should do this for us
var e = myArray.ToObject<DaxStudioTraceEventArgs[]>();
if (TraceCompleted != null)
{ TraceCompleted(this, e); }
}
示例2: DeserializeData
private static IList<object> DeserializeData(JArray data)
{
var list = data.ToObject<List<object>>();
for (int i = 0; i < list.Count; i++)
{
var value = list[i];
if (value is JObject)
list[i] = DeserializeData(value as JObject);
if (value is JArray)
list[i] = DeserializeData(value as JArray);
}
return list;
}
示例3: GetIndexes
private static IDictionary<WeatherChar, IDictionary<int, int>> GetIndexes(
JArray jHeaders, IEnumerable<WeatherChar> charList, IEnumerable<int> postCodeList)
{
IDictionary<WeatherChar, IDictionary<int, int>> result =
new Dictionary<WeatherChar, IDictionary<int, int>>();
var headers = jHeaders.ToObject<List<string>>();
foreach (WeatherChar ch in charList)
{
IDictionary<int, int> chResult = new Dictionary<int, int>();
foreach (int postCode in postCodeList)
{
chResult.Add(postCode,
headers.FindIndex(s => s.Contains(ch.ToString()) && s.Contains(postCode.ToString())));
}
result.Add(ch, chResult);
}
return result;
}
示例4: GetStoresOfOwner
public async void GetStoresOfOwner()
{
try
{
if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
{
JArray result = new JArray();
int ownerId = MediateClass.UserVM.UserInfo.UserId;
IDictionary<string, string> param = new Dictionary<string, string>
{
{"ownerId" , ownerId.ToString()}
};
var response = await App.MobileService.InvokeApiAsync("Stores", HttpMethod.Get, param);
result = JArray.Parse(response.ToString());
StoresOfOwner = result.ToObject<ObservableCollection<Kios>>();
}
}
catch (Exception ex)
{
await new MessageDialog(ex.Message.ToString(), "Get Store").ShowAsync();
}
}
示例5: GetSaleOfOwner
public async void GetSaleOfOwner(TYPEGET typeGet, TYPE type = TYPE.OLD)
{
try
{
JArray result = new JArray();
int lastId = -1;
if (typeGet == TYPEGET.MORE)
{
if (SaleOfStoreOwner.Count != 0)
{
if (type == TYPE.OLD)
lastId = SaleOfStoreOwner.Min(x => x.SaleId);
else
lastId = SaleOfStoreOwner.Max(x => x.SaleId);
}
}
int ownerId = MediateClass.UserVM.UserInfo.UserId;
SaleItem saleInfo = new SaleItem(lastId, ownerId, type);
JToken body = JToken.FromObject(saleInfo);
if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
{
var response = await App.MobileService.InvokeApiAsync("SaleInfoes", body, HttpMethod.Get, null);
result = JArray.Parse(response.ToString());
ObservableCollection<AdvertiseItem> more = result.ToObject<ObservableCollection<AdvertiseItem>>();
if (typeGet == TYPEGET.START)
{
SaleOfStoreOwner = more;
}
else
{
if (type == TYPE.OLD)
{
foreach (var item in more)
{
SaleOfStoreOwner.Add(item);
}
}
else
{
for (int i = 0; i < more.Count; i++)
{
SaleOfStoreOwner.Insert(i, more[i]);
}
}
}
}
}
catch (Exception ex)
{
await new MessageDialog(ex.Message.ToString(), "Load Sale").ShowAsync();
}
}
示例6: GetNewProductList
public async void GetNewProductList(TYPEGET typeGet, TYPE type = TYPE.OLD)
{
try
{
JArray result = new JArray();
int lastId = -1;
if (typeGet == TYPEGET.MORE)
{
if (NewProductList.Count != 0)
{
if (type == TYPE.OLD)
lastId = NewProductList.Min(x => x.ProductId);
else
lastId = NewProductList.Max(x => x.ProductId);
}
}
IDictionary<string, string> param = new Dictionary<string, string>
{
{"typeProduct" , type.ToString()},
{"productId" , lastId.ToString()}
};
if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
{
if (!isResponse)
{
isResponse = true;
var response = await App.MobileService.InvokeApiAsync("ProductStatistics", HttpMethod.Get, param);
result = JArray.Parse(response.ToString());
ObservableCollection<Product> more = result.ToObject<ObservableCollection<Product>>();
if (typeGet == TYPEGET.START)
{
NewProductList = more;
}
else
{
if (type == TYPE.OLD)
{
foreach (var item in more)
{
NewProductList.Add(item);
}
}
else
{
for (int i = 0; i < more.Count; i++)
{
NewProductList.Insert(i, more[i]);
}
}
}
}
}
}
catch (Exception ex)
{
await new MessageDialog(ex.Message.ToString(), "Load Product").ShowAsync();
}
finally
{
isResponse = false;
}
}
示例7: ParseResults
public List<MovieSearchResult> ParseResults(JToken token)
{
var items = new JArray(token.SelectTokens("[*].results").Cast<JArray>().SelectMany(a => a));
var result = items.ToObject<List<MovieSearchResult>>();
return result;
}
示例8: ParseMovies
public List<Movie> ParseMovies(JToken token)
{
int i = 0;
var items = new JArray(token.SelectTokens("[*].results").Cast<JArray>().SelectMany(a => a));
var result = items.ToObject<List<Movie>>();
result.ForEach(a => a.Source = items[i++].ToString(Formatting.Indented));
return result;
}