示例#1
0
        public UserEx()
        {
            BioEntities = new LinqToTwitter.Entities();
            UrlEntities = new LinqToTwitter.Entities();

            BlockUserCommand  = new LogMessageCommand("Tried to block user from UserEx", LogLevel.Warn);
            ReportSpamCommand = new LogMessageCommand("Tried to report user from UserEx", LogLevel.Warn);
        }
示例#2
0
 public DirectMessage(JsonData dmJson)
 {
     CreatedAt = dmJson.GetValue<string>("created_at").GetDate(DateTime.MinValue);
     SenderID = dmJson.GetValue<ulong>("sender_id");
     SenderScreenName = dmJson.GetValue<string>("sender_screen_name");
     Sender = new User(dmJson.GetValue<JsonData>("sender"));
     RecipientID = dmJson.GetValue<ulong>("recipient_id");
     RecipientScreenName = dmJson.GetValue<string>("recipient_screen_name");
     Recipient = new User(dmJson.GetValue<JsonData>("recipient"));
     IDResponse = dmJson.GetValue<ulong>("id");
     IDString = dmJson.GetValue<string>("id_str");
     Text = dmJson.GetValue<string>("text");
     Entities = new Entities(dmJson.GetValue<JsonData>("entities"));
 }
示例#3
0
        public void InstantiateEntities_WithNull_SuccessfullyCreatesEmptyCollectionProperties()
        {
            var emptyEntities = new Entities(null);

            Assert.IsNotNull(emptyEntities);
            Assert.IsNotNull(emptyEntities.HashTagEntities);
            Assert.IsFalse(emptyEntities.HashTagEntities.Any());
            Assert.IsNotNull(emptyEntities.MediaEntities);
            Assert.IsFalse(emptyEntities.MediaEntities.Any());
            Assert.IsNotNull(emptyEntities.SymbolEntities);
            Assert.IsFalse(emptyEntities.SymbolEntities.Any());
            Assert.IsNotNull(emptyEntities.UrlEntities);
            Assert.IsFalse(emptyEntities.UrlEntities.Any());
            Assert.IsNotNull(emptyEntities.UserMentionEntities);
            Assert.IsFalse(emptyEntities.UserMentionEntities.Any());
        }
示例#4
0
        public UserEx(JsonData user)
            : base(user)
        {
            var ent = user.GetValue <JsonData>("entities");

            UrlEntities = new LinqToTwitter.Entities(ent.GetValue <JsonData>("url"));
            BioEntities = new LinqToTwitter.Entities(ent.GetValue <JsonData>("description"))
            {
                HashTagEntities     = EntityParser.ExtractHashtags(Description),
                UserMentionEntities = EntityParser.ExtractMentions(Description)
            };

            UrlDisplay = Url;
            if (UrlEntities.UrlEntities.Any())
            {
                UrlDisplay = UrlEntities.UrlEntities.First().DisplayUrl;
            }
        }
示例#5
0
        public Status(JsonData status)
        {
            if (status == null) return;

            Retweeted = status.GetValue<bool>("retweeted");
            Source = status.GetValue<string>("source");
            InReplyToScreenName = status.GetValue<string>("in_reply_to_screen_name");
            PossiblySensitive = status.GetValue<bool>("possibly_sensitive");
            RetweetedStatus = new Status(status.GetValue<JsonData>("retweeted_status"));
            var contributors = status.GetValue<JsonData>("contributors");
            Contributors =
                contributors == null ?
                    new List<Contributor>() :
                    (from JsonData contributor in contributors
                     select new Contributor(contributor))
                    .ToList();
            var coords = status.GetValue<JsonData>("coordinates");
            if (coords != null)
            {
                Coordinates = new Coordinate(coords.GetValue<JsonData>("coordinates"));
            }
            else
            {
                Coordinates = new Coordinate();
            }
            Place = new Place(status.GetValue<JsonData>("place"));
            User = new User(status.GetValue<JsonData>("user"));
            RetweetCount = status.GetValue<int>("retweet_count");
            StatusID = status.GetValue<string>("id_str");
            FavoriteCount = status.GetValue<int?>("favorite_count");
            Favorited = status.GetValue<bool>("favorited");
            InReplyToStatusID = status.GetValue<string>("in_reply_to_status_id_str");
            Source = status.GetValue<string>("source");
            CreatedAt = status.GetValue<string>("created_at").GetDate(DateTime.MaxValue);
            InReplyToUserID = status.GetValue<string>("in_reply_to_user_id_str");
            Truncated = status.GetValue<bool>("truncated");
            Text = status.GetValue<string>("text");
            Annotation = new Annotation(status.GetValue<JsonData>("annotation"));
            Entities = new Entities(status.GetValue<JsonData>("entities"));
            var currentUserRetweet = status.GetValue<JsonData>("current_user_retweet");
            if (currentUserRetweet != null)
            {
                CurrentUserRetweet = currentUserRetweet.GetValue<ulong>("id");
            }
            var scopes = status.GetValue<JsonData>("scopes");
            Scopes =
                scopes == null ? new Dictionary<string, string>() :
                (from key in (scopes as IDictionary<string, JsonData>).Keys as List<string>
                 select new
                 {
                     Key = key,
                     Value = scopes[key].ToString()
                 })
                .ToDictionary(
                    key => key.Key,
                    val => val.Value);
            WithheldCopyright = status.GetValue<bool>("withheld_copyright");
            var withheldCountries = status.GetValue<JsonData>("withheld_in_countries");
            WithheldInCountries =
                withheldCountries == null ? new List<string>() :
                (from JsonData country in status.GetValue<JsonData>("withheld_in_countries")
                 select country.ToString())
                .ToList();
            WithheldScope = status.GetValue<string>("withheld_scope");
            MetaData = new StatusMetaData(status.GetValue<JsonData>("metadata"));
            Lang = status.GetValue<string>("lang");
            string filterLvl = status.GetValue<string>("filter_level");
            try
            {
                FilterLevel =
                    filterLvl == null ? FilterLevel.None :
                    (FilterLevel)Enum.Parse(typeof(FilterLevel), filterLvl, ignoreCase: true);
            }
            catch (ArgumentException)
            {
                FilterLevel = FilterLevel.None;
            }
        }
示例#6
0
 private static TwitterEntities Map(Entities entities)
 {
     return new TwitterEntities(Map(entities.UrlEntities), Map(entities.HashTagEntities),
         Map(entities.UserMentionEntities));
 }
示例#7
0
文件: UserEx.cs 项目: ichttt/Twice
 public UserEx()
 {
     BioEntities = new LinqToTwitter.Entities();
     UrlEntities = new LinqToTwitter.Entities();
 }