本文整理汇总了C#中Newtonsoft.Json.Linq.JArray.Values方法的典型用法代码示例。如果您正苦于以下问题:C# JArray.Values方法的具体用法?C# JArray.Values怎么用?C# JArray.Values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.Linq.JArray
的用法示例。
在下文中一共展示了JArray.Values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertAccounts
public void InsertAccounts(JArray accounts)
{
if (accounts != null && accounts.Count > 0)
{
foreach (var account in accounts.Values<JObject>())
{
InsertAccount(account);
}
}
}
示例2: AsyncStorageModule_testGetAllKeys
public void AsyncStorageModule_testGetAllKeys()
{
var mStorage = new AsyncStorageModule();
var waitHandle = new AutoResetEvent(false);
var error = default(JObject);
var result = default(JArray);
var callback = new MockCallback(res =>
{
error = res.Length > 0 ? (JObject)res[0] : null;
result = res.Length > 1 ? (JArray)res[1] : null;
waitHandle.Set();
});
mStorage.clear(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
var keys = new[] { "foo", "foo2" };
var values = new[] { "bar", "bar2" };
var keyValues = new[]
{
new[]
{
keys[0],
values[0],
},
new[]
{
keys[1],
values[1],
},
};
mStorage.multiSet(keyValues, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
mStorage.getAllKeys(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
var storedKeys = new JArray
{
keys[0],
keys[1],
};
var set = new SortedSet<string>();
IEnumerable<string> enumerator = storedKeys.Values<string>();
foreach (var value in enumerator)
{
set.Add(value);
}
set.SymmetricExceptWith(result.Values<string>());
Assert.AreEqual(set.Count, 0);
mStorage.multiRemove(keys, callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.IsNull(result);
mStorage.getAllKeys(callback);
Assert.IsTrue(waitHandle.WaitOne());
Assert.IsNull(error);
Assert.AreEqual(result.Count, 0);
}
示例3: RefreshCache
private void RefreshCache(JArray results)
{
try
{
this.AccessControl.WaitOne();
this.BlockRequests = true;
this.LastRefreshTime = DateTime.Now;
BiMap<int, string> newCache = new BiMap<int, string>(null, StringComparer.OrdinalIgnoreCase);
foreach (JObject obj in results.Values<JObject>())
{
int id = obj.GetId() ?? 0;
string label = this.Model.DisplayConverter(obj);
newCache.AddPair(id, label);
}
// I'm going to pray that assignment is atomic
this.PublicCache = newCache;
if (DataRefreshed != null)
DataRefreshed(this.PublicCache);
}
finally
{
this.BlockRequests = false;
this.AccessControl.ReleaseMutex();
}
}
示例4: LoadArray
public void LoadArray(JArray data)
{
this.CachedData = data;
this.CachedObjectTable = this.BuildCachedObjectTable();
this.Table = new DataTable();
// create hidden 'key' and 'model' fields so that each row can be re-attributed
// to a persistent instance later
var keyColumn = this.Table.Columns.Add(KeyColumn, typeof(int));
keyColumn.ReadOnly = true;
keyColumn.ColumnMapping = MappingType.Hidden;
var modelColumn = this.Table.Columns.Add(ModelColumn, typeof(string));
bool hideModel = this.ModelMappings.Count <= 1;
modelColumn.ReadOnly = true;
modelColumn.ColumnMapping = hideModel ? MappingType.Hidden : MappingType.Attribute;
foreach (string s in this.Columns)
{
DataColumn column = this.Table.Columns.Add(s, typeof(string));
column.Caption = s.SymbolToNatural();
DataColumn trueColumn = this.Table.Columns.Add(this.TrueColumnName(s), typeof(string));
trueColumn.ColumnMapping = MappingType.Hidden;
trueColumn.DefaultValue = null;
}
foreach (JObject dataObj in data.Values<JObject>())
{
this.AddRow(dataObj);
}
this.DataGrid.InvokeEx(() =>
{
this.DataGrid.DataSource = this.Table;
});
}
示例5: Init
public static Inventory Init(JArray items)
{
Inventory inventory = new Inventory();
//Separate books, cds, dvds
if (items != null && items.Count > 0)
{
IList<JObject> booklist = items.Values<JObject>().Where(x => x["type"].Value<string>() == "book").ToList();
IList<JObject> dvdlist = items.Values<JObject>().Where(x => x["type"].Value<string>() == "dvd").ToList();
IList<JObject> cdlist = items.Values<JObject>().Where(x => x["type"].Value<string>() == "cd").ToList();
try
{
foreach (var book in booklist)
inventory.Books.Add(JsonConvert.DeserializeObject<Book>(book.ToString()));
foreach (var dvd in dvdlist)
inventory.DVDs.Add(JsonConvert.DeserializeObject<DVD>(dvd.ToString()));
foreach (var cd in cdlist)
inventory.CDs.Add(JsonConvert.DeserializeObject<CD>(cd.ToString()));
}
catch ( Exception ex){
}
}
return inventory;
}
示例6: InsertOpportunities
public void InsertOpportunities(JArray opportunities)
{
if (opportunities != null && opportunities.Count > 0)
{
foreach (var opportunity in opportunities.Values<JObject>())
{
InsertOpportunity(opportunity);
}
}
}