/// <summary> /// User ViewModelを取得します。<para /> /// 内部キャッシュを更新します。 /// </summary> /// <param name="user">ユーザー情報(nullは指定できません)</param> public static UserViewModel Get(TwitterUser user) { if (user == null) throw new ArgumentNullException("user"); var newvm = new UserViewModel(user); dictionary.AddOrUpdate(user.ScreenName, newvm); return newvm; }
public EventDescription(EventKind kind, UserViewModel source, UserViewModel target, TweetViewModel tweet = null) { this.CreatedAt = DateTime.Now; this.Kind = kind; this.SourceUser = source; this.TargetUser = target; this.TargetTweet = tweet; }
public NotificationViewModel(MainWindowViewModel parent, UserViewModel source, UserViewModel target, string text, EventKind eventKind = EventKind.Undefined) { this.Parent = parent; this.SourceUser = source; this.TargetUser = target; this.Text = text; this.NotifyEventKind = eventKind; this.RaisePropertyChanged(() => SourceUser); this.RaisePropertyChanged(() => TargetUser); this.RaisePropertyChanged(() => Text); this.RaisePropertyChanged(() => NotifyEventKind); }
/// <summary> /// User ViewModelを取得します。<para /> /// 内部キャッシュを更新します。 /// </summary> /// <param name="user">ユーザー情報(nullは指定できません)</param> public static UserViewModel Get(TwitterUser user) { if (user == null) throw new ArgumentNullException("user"); var newvm = new UserViewModel(user); using (lockWrap.GetWriterLock()) { if (dictionary.ContainsKey(user.ScreenName)) dictionary[user.ScreenName] = newvm; else dictionary.Add(user.ScreenName, newvm); } return newvm; }
/// <summary> /// User ViewModelを取得します。<para /> /// nullを返すことがあります。 /// </summary> /// <param name="userScreenName">ユーザースクリーン名</param> /// <param name="useCache">内部キャッシュが可能であれば使用する</param> /// <returns></returns> public static UserViewModel Get(string userScreenName, bool useCache = true) { if (String.IsNullOrEmpty(userScreenName)) throw new ArgumentNullException("userScreenName", "userScreenNameがNullであるか、または空白です。"); UserViewModel ret = null; if (useCache && dictionary.TryGetValue(userScreenName, out ret)) { return ret; } else { var acc = AccountStorage.GetRandom(ai => true, true); if (acc != null) { try { var ud = acc.GetUserByScreenName(userScreenName); if (ud != null) { var uvm = new UserViewModel(ud); dictionary.AddOrUpdate(userScreenName, uvm); return uvm; } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "ユーザー情報の受信に失敗しました。(ユーザー @" + userScreenName + " を アカウント @" + acc.ScreenName + " で受信しようとしました。)"); } return null; } else { return null; } } }
public static void OnRetweeted(TweetViewModel tweet, UserViewModel retweeter) { if (AccountStorage.Contains(retweeter.TwitterUser.ScreenName) || tweet.CreatedAt < wakeupTime) return; Register(new EventDescription(EventKind.Retweet, retweeter, UserStorage.Get(tweet.Status.User), tweet)); }
public static void OnRemoved(UserViewModel fromUser, UserViewModel toUser) { Register(new EventDescription(EventKind.Unfollow, fromUser, toUser)); }
public static void OnUnfavored(TweetViewModel tweet, UserViewModel favorer) { if (AccountStorage.Contains(favorer.TwitterUser.ScreenName)) return; Register(new EventDescription(EventKind.Unfavorite, favorer, UserStorage.Get(tweet.Status.User), tweet)); }
public static bool IsFollowingCurrent(UserViewModel user, TabProperty property) { if (user == null) return false; return property.LinkAccountInfos.All(i => i.IsFollowing(user.TwitterUser.NumericId)); }
public static bool IsFollowingAny(UserViewModel user) { if (user == null) return false; return AccountStorage.Accounts.Any(d => d.Followings.Contains(user.TwitterUser.NumericId)); }
public static bool IsFollowerAny(UserViewModel user) { return AccountStorage.Accounts.Any(d => d.Followers.Contains(user.TwitterUser.NumericId)); }
public Relation(AccountInfo info, UserViewModel user) { this.Info = info; this.TargetUser = user; IsStandby = true; RefreshUserData(); }
/// <summary> /// 通知を発行する /// </summary> private static void IssueNotification(UserViewModel source, UserViewModel target, string text, EventKind eventKind, string soundPath = null) { if (Setting.Instance.StateProperty.IsInSilentMode) return; if (Setting.Instance.NotificationProperty.WindowNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled) { DispatcherHelper.BeginInvoke(() => { if (Setting.Instance.NotificationProperty.WindowNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive && Application.Current.MainWindow.IsActive) return; var nvm = new NotificationViewModel( Core.KernelService.MainWindowViewModel, source, target, text, eventKind); Core.KernelService.MainWindowViewModel.Messenger.Raise( new TransitionMessage(nvm, TransitionMode.Normal, "Notification")); }); } if (Setting.Instance.NotificationProperty.SoundNotificationStrategy != Configuration.Settings.NotificationStrategy.Disabled) { DispatcherHelper.BeginInvoke(() => { if (Setting.Instance.NotificationProperty.SoundNotificationStrategy == Configuration.Settings.NotificationStrategy.OnlyInactive && Application.Current.MainWindow.IsActive) return; PlaySound(eventKind, soundPath); }, System.Windows.Threading.DispatcherPriority.Background); } }
public R4SDialogViewModel(UserViewModel user, string receiver, string reason) { this.User = user; this.Receiver = receiver; this.Reason = reason; }
private void SetUserTimeline(UserViewModel user) { if (user == null) return; this.TimelineListCoreViewModel.Sources = new[] { new FilterUserId(user.TwitterUser.NumericId) }; Task.Factory.StartNew(() => this.TimelineListCoreViewModel.InvalidateCache()); }
public static void OnUnfavored(TweetViewModel tweet, UserViewModel favorer) { if (AccountStorage.Contains(favorer.TwitterUser.ScreenName) || !Setting.Instance.NotificationProperty.IsNotifyOthersFavoriteEnabled && !AccountStorage.Contains(tweet.Status.User.ScreenName)) return; Register(new EventDescription(EventKind.Unfavorite, favorer, UserStorage.Get(tweet.Status.User), tweet)); }
public FollowManagerViewModel(UserViewModel target) { this.Target = target; }
/// <summary> /// ユーザー情報をダウンロードし、キャッシュを更新します。 /// </summary> private static UserViewModel DownloadUser(string userScreenName) { ManualResetEvent mre; lock (semaphoreAccessLocker) { if (!semaphores.TryGetValue(userScreenName, out mre)) { semaphores.Add(userScreenName, new ManualResetEvent(false)); } } if (mre != null) { mre.WaitOne(); return Get(userScreenName); } try { var acc = AccountStorage.GetRandom(ai => true, true); if (acc != null) { try { var ud = acc.GetUserByScreenName(userScreenName); if (ud != null) { var uvm = new UserViewModel(ud); using (lockWrap.GetWriterLock()) { if (dictionary.ContainsKey(userScreenName)) dictionary[userScreenName] = uvm; else dictionary.Add(userScreenName, uvm); } return uvm; } } catch (Exception e) { ExceptionStorage.Register(e, ExceptionCategory.TwitterError, "ユーザー情報の受信に失敗しました。(ユーザー @" + userScreenName + " を アカウント @" + acc.ScreenName + " で受信しようとしました。)"); } return null; } else { return null; } } finally { lock (semaphoreAccessLocker) { if (semaphores.ContainsKey(userScreenName)) { semaphores[userScreenName].Set(); semaphores.Remove(userScreenName); } } } }