本文整理汇总了C#中Model.List.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# List.ToList方法的具体用法?C# List.ToList怎么用?C# List.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.List
的用法示例。
在下文中一共展示了List.ToList方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
internal static string Build(List<TestAttribute> Categories)
{
string source = "";
var list = new List<string>();
Categories
.ToList()
.ForEach(c => list.Add(c.GetName()));
list.Sort();
var catParams = new string[] {
ExtentFlag.GetPlaceHolder("testCategory"),
ExtentFlag.GetPlaceHolder("testCategoryU")
};
list.ForEach(c =>
{
var catValues = new string[] {
c,
c.ToLower().Replace(" ", "")
};
source += SourceBuilder.Build(CategoryFilterHtml.GetOptionSource(), catParams, catValues);
});
return source;
}
示例2: OnNewReleases
private void OnNewReleases(object sender, RoutedEventArgs e)
{
_atlasViewMode = AtlasViewMode.NewReleasesView;
//Clear the playlist selection.
NavigationControl navigationControl = (NavigationControl)sender;
navigationControl.SelectPlaylist(null);
OnPlaylistSelectionChanged(navigationControl, e);
List<NewReleaseItem> newsItems = new List<NewReleaseItem>();
//Add artists that have new releases.
//System.Threading.Tasks.Task.Run(() =>
{
AlbumType filter = AlbumType.Album | AlbumType.Single;
DateTime cutoff = DateTime.Now.AddMonths(-3); //TODO: Data-drive this setting.
int maxSuggestions = 1; //TODO: Data-drive this setting.
FollowedArtistList followedArtists = SpotifyCacheService.GetFollowedArtists();
foreach (Artist followedArtist in followedArtists.ArtistItems.Items)
{
//Find if there's any new content available from this artist.
AlbumInfoList albums = SpotifyClientService.Client.GetArtistAlbums(followedArtist, filter);
foreach (AlbumInfo album in albums.Items)
{
//if (_userCache.SeenNewsItem(album.ID)) continue;
Album albumInfo = SpotifyClientService.Client.GetAlbum(album);
if (albumInfo.ReleaseDate > cutoff)
{
newsItems.Add(new NewReleaseItem(followedArtist, albumInfo));
if (newsItems.Count >= maxSuggestions)
break;
}
else
{
//Assume that albums are returned by Spotify by release date, descending.
//If we miss the cutoff, skip out.
break;
}
}
}
if (newsItems.Any())
{
Dispatcher.Invoke(() =>
{
//Display a popup.
//this.NewsFeedPopup.DataContext = new NewsFeedViewModel(newsItems, userCache);
//this.NewsFeedPopup.Width = this.RenderSize.Width * 0.8;
//this.NewsFeedPopup.Height = this.RenderSize.Height * 0.8;
//this.NewsFeedPopup.IsOpen = true;
});
}
}
//);
AtlasViewOptions viewOptions = new AtlasViewOptions(0);
this.AtlasView.ViewModel.CreateNewReleaseHierarchy(newsItems.ToList().AsReadOnly(), viewOptions);
this.AtlasView.UpdateNetwork();
}
示例3: Generate
public void Generate() {
List<GetReservation_Result> ClientsToSeat = new List<GetReservation_Result>();
Table CurrentTable = new Table(_nbSeats);
bool goodFeeling;
bool found;
_tablesMaps = null;
_disliked = new List<Disliked>();
foreach(GetReservation_Result client in _clients.Where(client => client.IsValid == true)) {
ClientsToSeat.Add(client);
_disliked.Add(new Disliked(client.ClientId));
}
while(ClientsToSeat.Count > 0) {
foreach(GetReservation_Result CurrentClient in ClientsToSeat.ToList()) {
if(CurrentTable.HasRemainingSeats) {
goodFeeling = true;
foreach(GetReservation_Result seated in CurrentTable.Seateds) {
if(HasBadFeeling(CurrentClient.ClientId, seated.ClientId)) { // BR024
goodFeeling = false;
break;
}
}
if(goodFeeling) {
CurrentTable.Add(CurrentClient);
ClientsToSeat.Remove(CurrentClient);
}
} else {
break;
}
}
Tables.Add(CurrentTable);
CurrentTable = new Table(_nbSeats);
}
foreach(Table table in Tables.Where(table => !table.isValid).ToList()) {
if(table.Seateds.Count > 0) {
GetReservation_Result seated = table.Seateds[0];
foreach(Table otherTable in Tables.Where(tbl => tbl.isValid && tbl.HasRemainingSeats)) {
goodFeeling = true;
foreach(GetReservation_Result otherSeated in otherTable.Seateds) {
if(HasBadFeeling(seated.ClientId, otherSeated.ClientId)) { // BR024
goodFeeling = false;
break;
}
}
if(goodFeeling) {
otherTable.Add(seated);
Tables.Remove(table);
break;
}
}
} else {
Tables.Remove(table);
}
}
foreach(Table table in Tables.Where(table => !table.isValid).ToList()) {
GetReservation_Result seated = table.Seateds[0];
foreach(Table otherTable in Tables.Where(tbl => tbl.isValid && tbl.Seateds.Count > 2)) {
found = false;
foreach(GetReservation_Result otherSeated in otherTable.Seateds) {
if(!HasBadFeeling(seated.ClientId, otherSeated.ClientId)) { // BR024
otherTable.Seateds.Remove(otherSeated);
table.Add(seated);
found = true;
break;
}
}
if(found) {
break;
}
}
}
}
示例4: LoadProductsHome
public List<Pro_details_entity> LoadProductsHome(int _catid, int pos)
{
try
{
List<Pro_details_entity> l = new List<Pro_details_entity>();
if (pos == 3)
{
var list = ((from a in db.ESHOP_NEWS_CATs
join b in db.ESHOP_NEWs on a.NEWS_ID equals b.NEWS_ID
join c in db.ESHOP_CATEGORies on a.CAT_ID equals c.CAT_ID
where (c.CAT_ID == _catid || c.CAT_PARENT_PATH.Contains(_catid.ToString()))
select new { b.NEWS_ID, b.NEWS_TITLE, b.NEWS_IMAGE3, b.NEWS_DESC, b.NEWS_PRICE1, b.NEWS_PRICE2, b.NEWS_SEO_URL, b.NEWS_URL, b.NEWS_ORDER, b.NEWS_ORDER_PERIOD, b.NEWS_PUBLISHDATE, c.CAT_SEO_URL }).Distinct());
foreach (var i in list)
{
Pro_details_entity pro = new Pro_details_entity();
pro.NEWS_ID = i.NEWS_ID;
pro.NEWS_TITLE = i.NEWS_TITLE;
pro.NEWS_IMAGE3 = i.NEWS_IMAGE3;
pro.NEWS_DESC = i.NEWS_DESC;
pro.NEWS_SEO_URL = i.NEWS_SEO_URL;
pro.NEWS_URL = i.NEWS_URL;
pro.NEWS_ORDER = Utils.CIntDef(i.NEWS_ORDER);
pro.NEWS_ORDER_PERIOD = Utils.CIntDef(i.NEWS_ORDER_PERIOD);
pro.NEWS_PRICE1 = Utils.CDecDef(i.NEWS_PRICE1);
pro.NEWS_PRICE2 = Utils.CDecDef(i.NEWS_PRICE2);
pro.NEWS_PUBLISHDATE = Utils.CDateDef(i.NEWS_PUBLISHDATE, DateTime.Now);
pro.CAT_SEO_URL = i.CAT_SEO_URL;
l.Add(pro);
}
}
return l.ToList();
}
catch (Exception ex)
{
clsVproErrorHandler.HandlerError(ex);
return null;
}
}