當前位置: 首頁>>代碼示例>>C#>>正文


C# Activity.GetActors方法代碼示例

本文整理匯總了C#中Activity.GetActors方法的典型用法代碼示例。如果您正苦於以下問題:C# Activity.GetActors方法的具體用法?C# Activity.GetActors怎麽用?C# Activity.GetActors使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Activity的用法示例。


在下文中一共展示了Activity.GetActors方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateUserFollowedActivities

        protected virtual void CreateUserFollowedActivities(Activity activity)
        {
            //TODO: Run this method in a new thread (check connection creation)
            //TODO: Maybe optimized by creating a stored procedure?

            //Get user id's of all actors of this activity
            var actorUserIds = activity.GetActors().Cast<long>().ToList();
            if (actorUserIds.IsNullOrEmpty())
            {
                //No actor of this activity, so, no one will follow it.
                return;
            }

            //Get all followers of these actors
            var followerUserIds = GetFollowersOfUserIds(actorUserIds);

            //Add also actors (if not includes)
            followerUserIds = followerUserIds.Union(actorUserIds).ToList();

            //Get id's of all related users of this activity
            var relatedUserIds = activity.GetRelatedUsers().Cast<long>().ToList();

            //Add also related users (if not includes)
            followerUserIds = followerUserIds.Union(relatedUserIds).ToList();

            //Add one entity for each follower and actor
            foreach (var followerUserId in followerUserIds)
            {
                _userFollowedActivityRepository.Insert(
                    new UserFollowedActivity
                        {
                            User = _userRepository.Load(followerUserId),
                            Activity = activity,
                            IsActor = actorUserIds.Contains(followerUserId),
                            IsRelated = relatedUserIds.Contains(followerUserId)
                        });
            }
        }
開發者ID:flaithbheartaigh,項目名稱:taskever,代碼行數:38,代碼來源:ActivityService.cs


注:本文中的Activity.GetActors方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。