当前位置: 首页>>代码示例>>C#>>正文


C# List.Any方法代码示例

本文整理汇总了C#中Model.List.Any方法的典型用法代码示例。如果您正苦于以下问题:C# List.Any方法的具体用法?C# List.Any怎么用?C# List.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.List的用法示例。


在下文中一共展示了List.Any方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessUncommited

		void ProcessUncommited(ISignal<UncommitedEventStream> signal)
		{
			var uncommited = signal.Payload;
			var root = uncommited.Root;
			if (!uncommited.Events.Any())
			{
				signal.Return(new IDomainEvent[0]);
				return;
			}

			var last = _storage.LoadLast(root.Id);
			var toCommit = uncommited.Events;
			var commited = new List<IDomainEvent>();

			var targetVersion = last != null ? last.TargetVersion + last.Events.Count : 0;
			var currentVersion = targetVersion;
			foreach (var ev in toCommit)
			{
				if (currentVersion != ev.Version)
				{
					throw new ConcurrencyException(signal.Payload.Root, ev);
				}

				commited.Add(ev);
				currentVersion++;
			}

			var commitId = last != null ? last.Id + 1 : 0;
			var snapshot = last != null ? last.Snapshot : null;
			var snapshotId = last != null ? last.SnapshotId : null;

			if (root is ISnapshotEnabled && last != null && ShouldBuildSnapshot(last))
			{
				snapshot = (root as ISnapshotEnabled).BuildSnapshot();
				snapshotId = commitId;
			}

			if (commited.Any())
			{
				var commit = new Commit(
					commitId,
					root.Id,
					targetVersion,
					commited,
					snapshotId,
					snapshot
					);

				_storage.Store(commit);
			}

			signal.Return(uncommited.Events);
		}
开发者ID:Kostassoid,项目名称:Nerve.EventStore,代码行数:53,代码来源:EventStreamProcessor.cs

示例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();
        }
开发者ID:kweinberg1,项目名称:SoundAtlas,代码行数:64,代码来源:MainWindow.xaml.cs

示例3: UpdateCashdrawList

        public ActionResult UpdateCashdrawList(string idstr)
        {
            if (!string.IsNullOrEmpty(idstr))
            {
                var str = idstr.TrimEnd(',');
                md_cashdraw_app_Bll cashdrawBll = new md_cashdraw_app_Bll();
                md_docter_Bll doctorBll = new md_docter_Bll();
                List<md_cashdraw_app> cashdrawlist = cashdrawBll.GetCashdrawByIds(str);
                string error = string.Empty;
                foreach (var item in cashdrawlist)
                {
                    item.opstatus = (int)Model.ConfigClass.CashdrawStatus.已处理;  ///批注By Andy:更新一次就调用一次数据库连接,对数据库性能有影响,建议传入需要更新的ids,用update语句一次执行
                }
                cashdrawBll.UpdateChashdrawList(cashdrawlist, out error);

                var doctorids = cashdrawlist.Select(m => m.drid).Distinct().ToList();
                var doctorlist = doctorBll.GetDoctorByIds(doctorids);

                List<md_docter> doctors = new List<md_docter>();
                List<md_dr_account> dr_accountlist = new List<md_dr_account>();
                foreach (var item in doctorlist)
                {
                    var list = cashdrawlist.Where(m => m.drid == item.pkid.ToString()).ToList();
                    if (list.Any())
                    {
                        var money = list.Select(m => m.drawmoney).Sum();
                        item.current_income -= money;
                        doctors.Add(item);
                        md_dr_account accountinfo = new md_dr_account();
                        accountinfo.Initial();
                        accountinfo.dr_id = item.pkid;
                        accountinfo.income_type = 0;
                        accountinfo.money = money;
                        dr_accountlist.Add(accountinfo);
                    }
                }
                if (doctors.Any())
                {
                    doctorBll.UpdateChashdrawList(doctors, out error);
                }
                if (dr_accountlist.Any())
                {
                    new md_account_Bll().CreateAccountList(dr_accountlist, out error);
                }

            }

            return View();
        }
开发者ID:lehprject,项目名称:sfjyDMS,代码行数:49,代码来源:DoctorController.cs

示例4: getSeriesId

        public int getSeriesId(string seriesName)
        {
            // TODO: A few things here.  We should add more intelligence when there is more then 1 match
            // Things like default to (US) or (UK) or what ever is usally the case.  Also, perhaps a global setting that would always take newest series first...

            if (this.IsSeriesIgnored(seriesName))
            {
                return 0;
            }

            if (this.seriesIDMapping.Keys.Contains(seriesName, StringComparer.InvariantCultureIgnoreCase))
            {
                var seriesid = this.seriesIDMapping[seriesName];
                log.DebugFormat("SD-TvDb: Direct mapping: series: {0} id: {1}", seriesName, seriesid);
                return seriesid;
            }

            if (seriesCache.Keys.Contains(seriesName, StringComparer.InvariantCultureIgnoreCase))
            {
                log.DebugFormat("SD-TvDb: Series cache hit: {0} has id: {1}", seriesName, seriesCache[seriesName]);
                return seriesCache[seriesName];
            }

            string searchSeries = seriesName;

            if (IsSeriesInMappedSeries(seriesName))
            {
                searchSeries = this.seriesNameMapping[seriesName];
            }
            else if (this.seriesNameRegex.Count > 0)
            {
                foreach (string regexEntry in seriesNameRegex.Keys)
                {
                    var regex = new Regex(regexEntry);
                    if (regex.IsMatch(seriesName))
                    {
                        if (seriesNameRegex[regexEntry].StartsWith("replace="))
                        {
                            searchSeries = regex.Replace(seriesName, seriesNameRegex[regexEntry].Substring(8));
                        }
                        else if (seriesNameRegex[regexEntry].StartsWith("id="))
                        {
                            return int.Parse(seriesNameRegex[regexEntry].Substring(3));
                        }
                        else
                        {
                            searchSeries = seriesNameRegex[regexEntry];
                        }

                        log.DebugFormat("SD-TvDb: Regex mapping: series: {0} regex: {1} seriesMatch: {2}", seriesName, regexEntry, searchSeries);
                        break;
                    }
                }
            }

            List<TvdbSearchResult> searchResults = this.tvDbService.SearchSeries(searchSeries, this.language);

            log.DebugFormat("SD-TvDb: Search for {0} return {1} results", searchSeries, searchResults.Count);

            var seriesWithoutPunctuation = Regex.Replace(searchSeries, REMOVE_PUNCTUATION, string.Empty);
            if (searchResults.Count >= 1)
            {
                for (int i = 0; i < searchResults.Count; i++)
                {
                    var sn = new List<string> { Regex.Replace(searchResults[i].SeriesName, REMOVE_PUNCTUATION, string.Empty) };
                    sn.AddRange(searchResults[i].AliasNames.Select(x => Regex.Replace(x, REMOVE_PUNCTUATION, string.Empty)));
                    if (sn.Any(x => x.Equals(seriesWithoutPunctuation, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        var seriesId = searchResults[i].Id;
                        log.DebugFormat("SD-TvDb: series: {0} id: {1}", searchSeries, seriesId);
                        seriesCache.Add(seriesName, seriesId);
                        return seriesId;
                    }
                }

                log.DebugFormat("SD-TvDb: Could not find series match: {0} renamed {1}", seriesName, searchSeries);
            }

            log.DebugFormat("Cannot find series ID for {0}", seriesName);
            return 0;
        }
开发者ID:Christoph21x,项目名称:ARGUS-TV-GuideEnhancer,代码行数:81,代码来源:TvdbLibAccess.cs

示例5: FitCourses

 /// <summary>
 /// list of courses
 /// timetable
 /// 
 /// for each course in the list of courses
 ///     try to fit this course in the timetable
 ///         fit is found: 
 ///             fit course in a copy of the timetable
 ///             make a copy of the list of courses and remove the reference to this course (shallow)
 ///             call this method with the copied list and timetable
 ///         fit is not found:
 ///             try the next course in the list of courses
 /// </summary>
 private bool FitCourses(List<Course> courses, Timetable timetable)
 {
     int before = GeneratedTables.Count;
     if (courses.Any())
     {
         foreach (Course course in courses)
         {
             // TODO: optimise for speed by combining check and actually fitting
             if (timetable.CanFit(course))
             {
                 // Clone the list of courses left to fit
                 List<Course> coursesLeft = (List<Course>)courses.Clone();
                 // Remove the course that's going to be fitted from this cloned list
                 coursesLeft.Remove(course);
                 // Clone the timetable
                 Timetable newTimetable = (Timetable)timetable.Clone();
                 // Fit the course in the cloned timetable
                 newTimetable.Fit(course);
                 // Try to fit the remaining courses
                 FitCourses(coursesLeft, newTimetable);
             }
         }
     }
     else
     {
         bool added = GeneratedTables.Add(timetable);
         string output = String.Format("Item was added? {0}", added);
         Console.Out.WriteLine(output);
     }
     return before < GeneratedTables.Count;
 }
开发者ID:cverhelst,项目名称:Timetable,代码行数:44,代码来源:TimetableFitter.cs

示例6: Activate

 /// <summary>
 /// Handler for <see cref="Page.OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs)" />.
 /// </summary>
 /// <param name="parameter"><see cref="Windows.UI.Xaml.Navigation.NavigationEventArgs.Parameter" />.</param>
 public async void Activate(object parameter)
 {
     string lsActivityID = parameter as string;
     MSHealthActivities loActivities = null;
     MSHealthSplitDistanceType loDistanceType = MSHealthSplitDistanceType.None;
     MSHealthActivityInclude loInclude = MSHealthActivityInclude.Details | MSHealthActivityInclude.MapPoints;
     IsLoaded = false;
     Activity = null;
     TotalDistance = null;
     DistanceUnitShort = null;
     Pace = null;
     Splits = null;
     HeartRateZones = null;
     MapPath = null;
     ElevationGain = null;
     ElevationLoss = null;
     MaxElevation = null;
     MinElevation = null;
     IsElevationAvailable = false;
     IsHeartRateZonesAvailable = false;
     IsNikePlusAvailable = false;
     List<HeartRateZoneItem> loHeartRateZones = null;
     // Set back button visible (for Windows app)
     SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
     // Check parameter (Activity ID)
     if (!string.IsNullOrEmpty(lsActivityID))
     {
         IsRunningRequest = true;
         // Determine Distance Unit
         switch (Settings.MSHealthFilterDistance)
         {
             case DistanceUnit.DISTANCE_MILE:
                 loDistanceType = MSHealthSplitDistanceType.Mile;
                 DistanceUnitShort = Resources.Strings.TextDistanceUnitShortMileText;
                 break;
             case DistanceUnit.DISTANCE_KILOMETER:
                 loDistanceType = MSHealthSplitDistanceType.Kilometer;
                 DistanceUnitShort = Resources.Strings.TextDistanceUnitShortKilometerText;
                 break;
         }
         try
         {
             // Get Activity details
             loActivities = await moMSHealthClient.ListActivities(ids: lsActivityID,
                                                                  include: loInclude,
                                                                  splitDistanceType: loDistanceType);
             // Check Activity details returned
             if (loActivities.ItemCount > 0)
             {
                 // Map from derivated activities to single instance activity
                 if (loActivities.FreePlayActivities != null &&
                     loActivities.FreePlayActivities.Any())
                     Activity = loActivities.FreePlayActivities.FirstOrDefault();
                 else if (loActivities.RunActivities != null &&
                          loActivities.RunActivities.Any())
                     Activity = loActivities.RunActivities.FirstOrDefault();
                 else if (loActivities.BikeActivities != null &&
                          loActivities.BikeActivities.Any())
                     Activity = loActivities.BikeActivities.FirstOrDefault();
                 else if (loActivities.GolfActivities != null &&
                          loActivities.GolfActivities.Any())
                     Activity = loActivities.GolfActivities.FirstOrDefault();
                 else if (loActivities.GuidedWorkoutActivities != null &&
                          loActivities.GuidedWorkoutActivities.Any())
                     Activity = loActivities.GuidedWorkoutActivities.FirstOrDefault();
                 else if (loActivities.SleepActivities != null &&
                          loActivities.SleepActivities.Any())
                     Activity = loActivities.SleepActivities.FirstOrDefault();
                 else if (loActivities.HikeActivities != null &&
                          loActivities.HikeActivities.Any())
                     Activity = loActivities.HikeActivities.FirstOrDefault();
             }
             // Check current activity instance
             if (Activity != null)
             {
                 // Calculate Total Distance
                 if (Activity.SplitDistance != null &&
                     Activity.SplitDistance.HasValue &&
                     Activity.SplitDistance.Value > 0 &&
                     Activity.DistanceSummary != null &&
                     Activity.DistanceSummary.TotalDistance != null &&
                     Activity.DistanceSummary.TotalDistance.HasValue)
                 {
                     TotalDistance = (decimal)Activity.DistanceSummary.TotalDistance / (decimal)Activity.SplitDistance;
                 }
                 // Calculate Pace
                 if (Activity.DistanceSummary != null &&
                     Activity.DistanceSummary.Pace != null &&
                     Activity.DistanceSummary.Pace.HasValue)
                 {
                     Pace = TimeSpan.FromMilliseconds((double)Activity.DistanceSummary.Pace);
                 }
                 // Calculate Elevation
                 if (Activity.DistanceSummary != null)
                 {
                     // Elevation Gain
//.........这里部分代码省略.........
开发者ID:yorchideas,项目名称:XportBand,代码行数:101,代码来源:ActivityDetailsViewModel.cs


注:本文中的Model.List.Any方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。