public Hashtag GetOrCreateHashtag(string Tag, IMicroblog microblog) { lock (this) { string normalisedTagName = NormaliseTag(Tag); Hashtag tag; if (_hashtable.ContainsKey(normalisedTagName)) { tag = (Hashtag) _hashtable[normalisedTagName]; tag.AddSource(microblog); tag.Seen(); return tag; } tag = new Hashtag(Tag, microblog); _hashtable.Add(normalisedTagName, tag); Hashtags.Add(tag); return tag; } }
public TwitterProfileViewModel(IMicroblog source, IContact contact, TwitterClient twitterClient) : this() { _twitterClient = twitterClient; Source = source; Contact = contact; }
public UpdateTypeFilter(FilterBehaviour behaviour, IMicroblog blog, UpdateType updateType) { IsIncluded = behaviour; Microblog = blog; UpdateType = updateType; MicroblogAccountName = blog.Credentials.AccountName; MicroblogName = blog.Protocol; UpdateTypeName = UpdateType.GetType().AssemblyQualifiedName; if (UpdateType.SaveType) UpdateTypeParameter = UpdateType.Type; }
public bool TryFind(Credential credential, Action<IMicroblog> onCreate, out IMicroblog blog) { if (AvailableMicroblogs == null) AvailableMicroblogs = _composeMicroblogs(); blog = null; IMicroblogSource provider = AvailableMicroblogs.Any() ? AvailableMicroblogs.SingleOrDefault( b => b.Protocol.Matches(credential.Protocol)) : null; if (provider == null) return false; IPlugin newBlog = provider.Create(); if (newBlog == null) return false; blog = (IMicroblog) newBlog; blog.Credentials = credential; if (onCreate != null) onCreate(blog); if (blog is IHaveSettings) { var foundSettings = (blog as IHaveSettings); if (_pluginSettingsProvider.HasSettingsFor(blog)) foundSettings.LoadSettings(_pluginSettingsProvider); else foundSettings.LoadDefaultSettings(); foundSettings.OnSettingsUpdated(); } return true; }
public void UpdateMicroblogColor(IMicroblog imicroblog, UpdateType updatetype, Color color) { Filters.Include(imicroblog, updatetype, color); RaisePropertyChanged(() => Filters); }
public bool TryFind(Credential blogCredential, out IMicroblog blog) { return TryFind(blogCredential, null, out blog); }
public void HandleNewMicroblog(IMicroblog payload) { if (SelectedMicroblogs.Count == 0) SelectMicroblog(payload); }
public void UnselectMicroblog(IMicroblog blog) { if (!SelectedMicroblogs.Contains(blog)) return; SelectedMicroblogs.Remove(blog); }
public void SelectMicroblog(IMicroblog blog) { if (SelectedMicroblogs.Contains(blog)) return; if (blog.ReadOnly) return; SelectedMicroblogs.Add(blog); }
public IEnumerable<Filter> GetFiltersFor(IMicroblog microblog, UpdateType updateType) { IEnumerable<UpdateTypeFilter> filters = Filters.OfType<UpdateTypeFilter>(); IEnumerable<UpdateTypeFilter> foundFiltersForMicroblog = filters.Where( filter => filter.Microblog != null && filter.Microblog.Protocol.Matches(microblog.Protocol, true) && filter.Microblog.Credentials.AccountName.Matches(microblog.Credentials.AccountName, true)); if (!foundFiltersForMicroblog.Any()) return new List<Filter>(); IEnumerable<UpdateTypeFilter> foundFiltersForUpdate = foundFiltersForMicroblog.Where( filter => (filter.UpdateType != null) ? filter.UpdateType.Type.Matches(updateType.Type, true) : false); if (!foundFiltersForUpdate.Any()) return new List<Filter>(); return foundFiltersForUpdate.Cast<Filter>().ToList(); }
public void UpdateMicroblogColor(IMicroblog imicroblog, UpdateType updatetype, Color color) { StreamConfiguration.UpdateMicroblogColor(imicroblog, updatetype, color); }
public void SetMicroblog(IMicroblog findMicroblog) { Microblog = findMicroblog; }
public void Include(IMicroblog blog, UpdateType updateType) { IEnumerable<Filter> filters = GetFiltersFor(blog, updateType); if (filters.Any()) { foreach (Filter ff in filters) { ff.IsIncluded = FilterBehaviour.Include; } return; } var fs = new UpdateTypeFilter(FilterBehaviour.Include, blog, updateType); Filters.Add(fs); }
public void RemoveExclude(IMicroblog blog, UpdateType updateType) { IEnumerable<Filter> foundFilters = GetFiltersFor(blog, updateType); foreach (Filter filter in foundFilters) Filters.Remove(filter); }
public void IgnoreStream(IMicroblog blog, UpdateType updateType) { Filters.Exclude(blog, updateType); RaisePropertyChanged(() => Filters); }
public void AddParent(IMicroblog parent) { if (!Parents.Any(microblog => microblog.Owner.Name.Matches(parent.Owner.Name))) Parents.Add(parent); }
public static Tweet CreateTweet(MahApps.Twitter.Models.Tweet s, TwitterContact contact, IMicroblog source) { if (s.RetweetedStatus != null) return CreateRetweet(s, contact); if (contact.ImageUrl != new Uri(s.User.ProfileImageUrl)) contact.SetContactImage(new Uri(s.User.ProfileImageUrl), s.Created); contact.Bio = s.User.Description; contact.Following = s.User.FriendsCount; contact.Followers = s.User.FollowersCount; contact.FullName = s.User.Name; var t = new Tweet { ID = s.Id.ToString(), Contact = contact, Text = WebUtility.HtmlDecode(s.Text), Time = s.Created.ToLocalTime(), SourceUri = s.Source.GetSourceURL(), Source = s.Source.GetSourceText(), Favourite = s.Favourited, Microblog = source, }; if (s.Coordinates != null && s.Coordinates.Lat != null && s.Coordinates.Long != null) t.Location = new GeoLocation((double) s.Coordinates.Lat, (double) s.Coordinates.Long); if (s.InReplyToStatusId > 0) { t.InReplyToID = s.InReplyToStatusId.ToString(); t.InReplyTo = new Contact {Name = s.InReplyToScreenName}; } t.AddParent(source); return t; }