Inline CreateUrlLink(TwitterUrl URL) { MenuItem item = new MenuItem { Header = Localization.Resources.MuteDomain, Foreground = new SolidColorBrush(Colors.Black) }; item.Click += (sender, e) => { Uri uri; if (Uri.TryCreate(URL.ExpandedValue, UriKind.Absolute, out uri)) { var filter = FilterManager.SetupMute(FilterType.Text, uri.Host); Dependency.Resolve <IMessageService>().ShowMessage(String.Format(Localization.Resources.MutedUntil, filter.IsValidUntil.ToString("f")), ""); } else { Dependency.Resolve <IMessageService>().ShowError(Localization.Resources.NotValidURL); } }; string value = string.IsNullOrWhiteSpace(URL.ExpandedValue) ? URL.Value : URL.ExpandedValue; return(CreateBaseLink(TweetTextConverter.TrimUrl(value), Localization.Resources.CopyLink, value, item)); }
public void Execute(object parameter) { TwitterStatus tweet = parameter as TwitterStatus; _pendingCalls = 0; var credentials = Config.ReadLaterCredentials; if (tweet == null) { return; } if (credentials.Pocket != null) { var service = new PocketService(); service.UserName = credentials.Pocket.User; service.Password = credentials.Pocket.Password; TwitterUrl link = tweet.Entities.FirstOrDefault(item => item != null && item.EntityType == TwitterEntityType.Url) as TwitterUrl; Dependency.Resolve <IMessageService>().SetLoadingBar(true, Resources.SavingForLater); _pendingCalls++; if (link != null) { service.AddUrl(link.ExpandedValue, tweet.Id, Callback); } else { string url = "http://twitter.com/" + tweet.Author.ScreenName + "/statuses/" + tweet.Id.ToString(); service.AddUrl(url, Callback); } } if (credentials.Instapaper != null) { var service = new InstapaperService(); service.UserName = credentials.Instapaper.User; service.Password = credentials.Instapaper.Password; TwitterUrl link = tweet.Entities.FirstOrDefault(item => item != null && item.EntityType == TwitterEntityType.Url) as TwitterUrl; Dependency.Resolve <IMessageService>().SetLoadingBar(true, Resources.SavingForLater); _pendingCalls++; if (link != null) { service.AddUrl(link.ExpandedValue, tweet.Text, Callback); } else { string url = "http://twitter.com/" + tweet.Author.ScreenName + "/statuses/" + tweet.Id.ToString(); service.AddUrl(url, Callback); } } }
public AboutDataModel Clone() { return(new AboutDataModel { _id = _id, Title = (string)Title.Clone(), SubTitle = (string)SubTitle.Clone(), Description = Description.Select(d => d.Clone()).Cast <string>().ToList(), FacebookUrl = (string)FacebookUrl.Clone(), GooglePlusUrl = (string)GooglePlusUrl.Clone(), Image = Image.Clone(), LinkedInUrl = (string)LinkedInUrl.Clone(), TwitterUrl = (string)TwitterUrl.Clone() }); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // Overflow is fine, just wrap unchecked { var hashCode = 41; // Suitable nullity checks etc, of course :) #pragma warning disable CA1307 // Specify StringComparison // ReSharper disable once NonReadonlyMemberInGetHashCode if (FirstName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + FirstName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (LastName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + LastName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (CompanyName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + CompanyName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (CompanyUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + CompanyUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Description != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Description.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (BlogsUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + BlogsUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (ContactsUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + ContactsUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (TwitterUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + TwitterUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (HabrUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + HabrUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (GitHubUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + GitHubUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (MeetupIds != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + MeetupIds.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (TalkIds != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + TalkIds.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (VenueIds != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + VenueIds.GetHashCode(); } #pragma warning restore CA1307 // Specify StringComparison return(hashCode); } }
/// <inheritdoc /> /// <summary> /// Returns true if UpdateSpeakerDraftParameters instances are equal /// </summary> /// <param name="other">Instance of UpdateSpeakerDraftParameters to be compared</param> /// <returns>Boolean</returns> public bool Equals(UpdateSpeakerDraftParameters other) { #pragma warning disable IDE0041 // Use 'is null' check if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } #pragma warning disable CA1309 // Use ordinal stringcomparison #pragma warning disable CA1307 // Specify StringComparison #pragma warning disable SA1515 // Single-line comment must be preceded by blank line #pragma warning disable SA1009 // Closing parenthesis must be spaced correctly return (#pragma warning disable SA1119 // Statement must not use unnecessary parenthesis ( // ReSharper disable once RedundantNameQualifier string.Equals(FirstName, other.FirstName) || (FirstName != null && FirstName.Equals(other.FirstName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(LastName, other.LastName) || (LastName != null && LastName.Equals(other.LastName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(CompanyName, other.CompanyName) || (CompanyName != null && CompanyName.Equals(other.CompanyName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(CompanyUrl, other.CompanyUrl) || (CompanyUrl != null && CompanyUrl.Equals(other.CompanyUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(Description, other.Description) || (Description != null && Description.Equals(other.Description)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(BlogsUrl, other.BlogsUrl) || (BlogsUrl != null && BlogsUrl.Equals(other.BlogsUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(ContactsUrl, other.ContactsUrl) || (ContactsUrl != null && ContactsUrl.Equals(other.ContactsUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(TwitterUrl, other.TwitterUrl) || (TwitterUrl != null && TwitterUrl.Equals(other.TwitterUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(HabrUrl, other.HabrUrl) || (HabrUrl != null && HabrUrl.Equals(other.HabrUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(GitHubUrl, other.GitHubUrl) || (GitHubUrl != null && GitHubUrl.Equals(other.GitHubUrl)) ) && ( MeetupIds == other.MeetupIds || (MeetupIds != null && MeetupIds.SequenceEqual(other.MeetupIds)) ) && ( TalkIds == other.TalkIds || (TalkIds != null && TalkIds.SequenceEqual(other.TalkIds)) ) && ( VenueIds == other.VenueIds || (VenueIds != null && VenueIds.SequenceEqual(other.VenueIds)) )); #pragma warning restore SA1119 // Statement must not use unnecessary parenthesis #pragma warning restore SA1009 // Closing parenthesis must be spaced correctly #pragma warning restore SA1515 // Single-line comment must be preceded by blank line #pragma warning restore CA1307 // Specify StringComparison #pragma warning restore CA1309 // Use ordinal stringcomparison }
Inline CreateUrlLink(TwitterUrl URL) { MenuItem item = new MenuItem { Header = Localization.Resources.MuteDomain, Foreground = new SolidColorBrush(Colors.Black) }; item.Click += (sender, e) => { Uri uri; if (Uri.TryCreate(URL.ExpandedValue, UriKind.Absolute, out uri)) { var filter = FilterManager.SetupMute(FilterType.Text, uri.Host); Dependency.Resolve<IMessageService>().ShowMessage(String.Format(Localization.Resources.MutedUntil, filter.IsValidUntil.ToString("f")), ""); } else Dependency.Resolve<IMessageService>().ShowError(Localization.Resources.NotValidURL); }; string value = string.IsNullOrWhiteSpace(URL.ExpandedValue) ? URL.Value : URL.ExpandedValue; return CreateBaseLink(TweetTextConverter.TrimUrl(value), Localization.Resources.CopyLink, value, item); }
private void ProcessTwitterTweets(string blobText, T_CollectionTask t_newTask) { //1-Deserialize List <T_TwitterTweet> t_tweets = new List <T_TwitterTweet>(); List <T_TwitterGeoLocation> t_geoLocations = new List <T_TwitterGeoLocation>(); List <T_TwitterPlace> t_places = new List <T_TwitterPlace>(); List <T_TwitterHashTag> t_hashTags = new List <T_TwitterHashTag>(); List <T_TwitterMedia> t_medias = new List <T_TwitterMedia>(); List <T_TwitterMention> t_mentions = new List <T_TwitterMention>(); List <T_TwitterUrl> t_urls = new List <T_TwitterUrl>(); List <TwitterStatus> tweets = JsonConvert.DeserializeObject <List <TwitterStatus> >(blobText); #region Tweets foreach (TwitterStatus tweet in tweets) { T_TwitterTweet t_tweet = new T_TwitterTweet(); t_tweet.CollectionTaskId = t_newTask.Id; t_tweet.CreatedDate = tweet.CreatedDate; t_tweet.InReplayToTweetId = tweet.InReplyToStatusId; t_tweet.InReplayToUserId = tweet.InReplyToUserId; t_tweet.InReplyToScreenName = tweet.InReplyToScreenName; t_tweet.IsFavorited = tweet.IsFavorited; t_tweet.IsPossiblySensitive = tweet.IsPossiblySensitive; t_tweet.IsTruncated = tweet.IsTruncated; t_tweet.RetweetCount = tweet.RetweetCount; t_tweet.Source = tweet.Source; t_tweet.Text = tweet.Text; t_tweet.TweeterId = tweet.User.Id; t_tweet.TweeterScreenName = tweet.User.ScreenName; t_tweet.TweetId = tweet.Id; t_tweets.Add(t_tweet); if (tweet.Location != null) { T_TwitterGeoLocation t_geoLocation = new T_TwitterGeoLocation(); t_geoLocation.CollectionTaskId = t_newTask.Id; t_geoLocation.TweetId = t_tweet.TweetId; t_geoLocation.TweeterUserId = t_tweet.TweeterId; t_geoLocation.Longitude = Math.Round(Convert.ToDecimal(tweet.Location.Coordinates.Longitude), 6); t_geoLocation.Latitude = Math.Round(Convert.ToDecimal(tweet.Location.Coordinates.Latitude), 6); t_geoLocations.Add(t_geoLocation); } if (tweet.Place != null) { T_TwitterPlace t_place = new T_TwitterPlace(); t_place.CollectionTaskId = t_newTask.Id; t_place.TweetId = t_tweet.TweetId; t_place.TweeterUserId = t_tweet.TweeterId; t_place.Country = tweet.Place.Country; t_place.CountryCode = tweet.Place.CountryCode; t_place.FullName = tweet.Place.FullName; t_place.Name = tweet.Place.Name; t_place.PlaceId = tweet.Place.Id; t_place.PlaceType = tweet.Place.PlaceType.ToString(); t_place.Url = tweet.Place.Url; t_places.Add(t_place); } if (tweet.Entities != null) { if (tweet.Entities.Count <TwitterEntity>() > 0) { foreach (TwitterEntity entity in tweet.Entities) { switch (entity.EntityType) { case TwitterEntityType.HashTag: TwitterHashTag hashTag = (TwitterHashTag)entity; T_TwitterHashTag t_hashTag = new T_TwitterHashTag(); t_hashTag.CollectionTaskId = t_newTask.Id; t_hashTag.TweetId = t_tweet.TweetId; t_hashTag.TweeterUserId = t_tweet.TweeterId; t_hashTag.Text = hashTag.Text; t_hashTags.Add(t_hashTag); break; case TwitterEntityType.Media: TwitterMedia media = (TwitterMedia)entity; T_TwitterMedia t_media = new T_TwitterMedia(); t_media.CollectionTaskId = t_newTask.Id; t_media.TweetId = t_tweet.TweetId; t_media.TweeterUserId = t_tweet.TweeterId; t_media.DisplayUrl = media.DisplayUrl; t_media.ExpandedUrl = media.ExpandedUrl; t_media.MediaId = media.Id; t_media.MediaType = media.MediaType.ToString(); t_media.MediaUrl = media.MediaUrl; t_media.Url = media.Url; t_medias.Add(t_media); break; case TwitterEntityType.Mention: TwitterMention mention = (TwitterMention)entity; T_TwitterMention t_mention = new T_TwitterMention(); t_mention.CollectionTaskId = t_newTask.Id; t_mention.TweetId = t_tweet.TweetId; t_mention.TweeterUserId = t_tweet.TweeterId; t_mention.MentionId = mention.Id; t_mention.Name = mention.Name; t_mention.ScreenName = mention.ScreenName; t_mentions.Add(t_mention); break; case TwitterEntityType.Url: TwitterUrl url = (TwitterUrl)entity; T_TwitterUrl t_url = new T_TwitterUrl(); t_url.CollectionTaskId = t_newTask.Id; t_url.TweetId = t_tweet.TweetId; t_url.TweeterUserId = t_tweet.TweeterId; t_url.ExpandedValue = url.ExpandedValue; t_url.Value = url.Value; t_urls.Add(t_url); break; default: throw new NotImplementedException(); } } } } } #endregion //2-Validate //3-Update LinqToSqlAzureHaystackDataContext context = new LinqToSqlAzureHaystackDataContext(); context.T_TwitterTweets.InsertAllOnSubmit <T_TwitterTweet>(t_tweets); context.T_TwitterGeoLocations.InsertAllOnSubmit <T_TwitterGeoLocation>(t_geoLocations); context.T_TwitterPlaces.InsertAllOnSubmit <T_TwitterPlace>(t_places); context.T_TwitterHashTags.InsertAllOnSubmit <T_TwitterHashTag>(t_hashTags); context.T_TwitterMedias.InsertAllOnSubmit <T_TwitterMedia>(t_medias); context.T_TwitterMentions.InsertAllOnSubmit <T_TwitterMention>(t_mentions); context.T_TwitterUrls.InsertAllOnSubmit <T_TwitterUrl>(t_urls); context.SubmitChanges(); }
public static IEnumerable<TwitterUrl> ParseTwitterageToUrls(this string input) { if (input.IsNullOrBlank()) { yield break; } foreach (Match match in ParseUrls.Matches(input)) { var value = match.Value; Uri uri; try { uri = new Uri(value); } catch (Exception) { continue; } var url = new TwitterUrl { Value = uri.ToString(), Indices = new List<int>(new[] { match.Index, match.Index + match.Value.Length }) }; if (!match.Value.EndsWith("/") && url.Value.EndsWith("/")) { url.Value = url.Value.Substring(0, url.Value.Length - 1); } yield return url; } }