本文整理汇总了C#中Article.SetList方法的典型用法代码示例。如果您正苦于以下问题:C# Article.SetList方法的具体用法?C# Article.SetList怎么用?C# Article.SetList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article.SetList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetListTest
public void GetListTest()
{
var obj = new Article("object");
obj.SetList<int>("multifield", new[] { 1, 2, 3, 4, 5 });
var list = obj.GetList<decimal>("multifield");
Assert.IsTrue(list.Intersect(new decimal[] { 1, 2, 3, 4, 5 }).Count() == 5);
}
示例2: SaveMultivaluedAsyncTest
public async Task SaveMultivaluedAsyncTest()
{
var array = new[] { 1, 3, 4, 5, 6, 7 };
var obj = new Article("object");
obj.SetList<int>("multifield", array);
await obj.SaveAsync();
var saved = await Articles.GetAsync("object", obj.Id);
var array2 = saved.GetList<int>("multifield");
Assert.IsTrue(array.Intersect(array2).Count() == array.Length);
}
示例3: MultiValueArticleTest
public async Task MultiValueArticleTest()
{
var obj = new Article("object");
obj.SetList<string>("multifield", new[] { "1", "2", "3", "4" });
await obj.SaveAsync();
var read = await Articles.GetAsync("object", obj.Id);
var value = read.GetList<string>("multifield");
var strList = read.GetList<string>("multifield");
var intList = read.GetList<int>("multifield");
}
示例4: CannotGetMultiValuedViaIndexerTest
public void CannotGetMultiValuedViaIndexerTest()
{
var obj = new Article("object");
try
{
obj.SetList<int>("multifield", new int[] { 1, 2, 4 });
try
{
var list = obj["multifield"];
Assert.Fail("Set operation on multivalue indexer should have failed.");
}
catch (Exception)
{
}
}
catch (Exception)
{ }
}