本文整理汇总了C#中Data.List.Last方法的典型用法代码示例。如果您正苦于以下问题:C# List.Last方法的具体用法?C# List.Last怎么用?C# List.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.List
的用法示例。
在下文中一共展示了List.Last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DummyUserRatingsRepository
internal static IRepository<UserRating> DummyUserRatingsRepository()
{
var repo = new Mock<IRepository<UserRating>>();
var ratings = new List<UserRating>();
for (int i = 0; i < NumberOfTestObjects; i++)
{
ratings.Add(new UserRating
{
Id = i,
ClientId = "TestId" + i,
HitmanId = "TestId" + (i % 2 == 0 ? i : 3),
Rating = i % 6
});
}
repo.Setup(r => r.All()).Returns(() =>
{
return ratings.AsQueryable();
});
repo.Setup(r => r.SaveChanges()).Returns(ratings.Last().Id);
repo.Setup(r => r.Add(It.IsAny<UserRating>())).Callback<UserRating>(ur =>
{
ur.Id = ratings.LastOrDefault().Id + 1;
ratings.Add(ur);
});
return repo.Object;
}
示例2: PopulateTimelineData
private static void PopulateTimelineData(List<ItemsViewModel> itemsDataP11, List<ItemsViewModel> itemsDataP14, List<DataItemViewModel> timelineData)
{
#region Rabadon
IList<DataItemViewModelAux> divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Rabadon"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Rabadon"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Needlessly
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Needlessly"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Needlessly"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Zhonya
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Zhonya"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Zhonya"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
#region Luden's Echo
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP11)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Luden"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
divm = new List<DataItemViewModelAux>();
foreach (var item in itemsDataP14)
{
var raba = item.Items.FirstOrDefault(i => i.Name.StartsWith("Luden"));
var pickrate = int.Parse(raba.PickRate.Replace("%", string.Empty));
if (pickrate > 15)
divm.Add(new DataItemViewModelAux { Minute = item.Minute, Name = raba.Name, Pickrate = pickrate });
}
timelineData.Add(new DataItemViewModel { Name = divm.First().Name, Patch = "5.11", MinuteFrom = divm.First().Minute, MinuteTo = divm.Last().Minute });
#endregion
}
示例3: DummyImagesRepository
internal static IRepository<Image> DummyImagesRepository()
{
var repository = new Mock<IRepository<Image>>();
var images = new List<Image>();
for (int i = 0; i < NumberOfTestObjects; i++)
{
var user = DummyHitmenRepository()
.All()
.FirstOrDefault(u => u.Id == i.ToString());
images.Add(new Image()
{
Id = i,
Name = "Image #" + i,
Extension = ".png",
UserId = user.Id,
User = user
});
}
repository.Setup(r => r.All()).Returns(() =>
{
return images.AsQueryable();
});
repository
.Setup(r => r.Add(It.IsAny<Image>()))
.Callback<Image>(i =>
{
i.Id = images.LastOrDefault().Id + 1;
images.Add(i);
});
repository.Setup(r => r.SaveChanges()).Returns(images.Last().Id);
repository
.Setup(r => r.Delete(It.IsAny<Image>()))
.Callback<Image>(i =>
{
images.RemoveAt(i.Id);
});
return repository.Object;
}