Пример #1
0
		public static IEnumerable<RichText> ToRichText(this Status status)
		{
			var list = new List<RichText>();
			var current = 0;
			status.Entities.UserMentions.Select(m => new
				{
					m.Indices,
					RichText = (RichText)new Mention
					{
						Text = status.Text.Substring(m.Indices.StartIndex, m.Indices.Length),
						User = m.User
					}
				})
				.Concat(status.Entities.Hashtags.Select(h => new
				{
					h.Indices,
					RichText = (RichText)new Ctrls.Hashtag
					{
						Text = status.Text.Substring(h.Indices.StartIndex, h.Indices.Length)
					}
				}))
				.Concat(status.Entities.Urls.Select(u => new
				{
					u.Indices,
					RichText = (RichText)new Ctrls.Url
					{
						Text = u.DisplayUrl ?? status.Text.Substring(u.Indices.StartIndex, u.Indices.Length),
						Uri = u.ExpandedUrl ?? u.EntityUrl,
					}
				}))
				.Concat(status.Entities.Media.Select(m => new
				{
					m.Indices,
					RichText = (RichText)new Ctrls.Url
					{
						//Text = m.MediaUrlHttps != null
						//	? m.MediaUrlHttps.ToString()
						//	: m.DisplayUrl ?? status.Text.Substring(m.Indices.StartIndex, m.Indices.Length),
						Text = m.DisplayUrl ?? status.Text.Substring(m.Indices.StartIndex, m.Indices.Length),
						Uri = m.ExpandedUrl ?? m.MediaUrl
					}
				}))
				.OrderBy(a => a.Indices.StartIndex)
				.ForEach(e =>
				{
					if (e.Indices.StartIndex - current > 0)
					{
						list.Add(new Regular { Text = status.Text.Substring(current, e.Indices.StartIndex - current).DecodeCER() });
					}
					list.Add(e.RichText);
					current = e.Indices.EndIndex;
				});

			if (current < status.Text.Length)
			{
				list.Add(new Regular { Text = status.Text.Substring(current).DecodeCER() });
			}

			return list;
		}
Пример #2
0
		internal static Error[] ParseCore(dynamic djson)
		{
			var list = new List<Error>();
			foreach (var e in (object[])djson.errors)
			{
				try
				{
					var error = Error.ParseCore(e);
					list.Add(error);
				}
				catch (Exception ex)
				{
					ex.Write();
				}
			}
			return list.ToArray();
		}
Пример #3
0
		public static ICollection<List> Parse(string json, UserId ownerId)
		{
			var djson = DynamicJsonHelper.ToDynamicJson(json);

			DynamicJsonHelper.ThrowIfError(djson);

			var lists = new List<List>();
			try
			{
				foreach (var l in (object[])djson)
				{
					List list;
					if (TwitterClient.Current.Lists.TryParse(l, ownerId, out list)) lists.Add(list);
				}
			}
			catch (Exception ex)
			{
				throw new JsonParseException(json, typeof(StatusCollection), ex);
			}

			return lists;
		}
Пример #4
0
		public ListViewModel(List list, Action checkAction)
		{
			this.List = list;
			this.checkAction = checkAction;
		}
Пример #5
0
		/// <summary>
		///     タイムラインに受信対象リストを設定します。
		/// </summary>
		/// <param name="lists">受信対象リストのコレクション。すべてのツイートを受信する設定に戻す場合は null。</param>
		public void SetLists(ICollection<List> lists)
		{
			if (lists == null || lists.IsEmpty())
			{
				this.targets = null;
				if (this.Timeline != null)
				{
					this.Timeline.SubscribedLists = null;
				}
			}
			else
			{
				this.targets = lists as List<List> ?? lists.ToList();
				this.targets.ForEach(
					l => Helper.Operation(l.UpdateMembers, "リスト '{0}' のメンバーを取得できませんでした。", l.HasDetails ? l.FullName : "id:" + l.Id));

				if (this.Timeline != null)
				{
					this.Timeline.SubscribedLists = this.targets;
				}
			}

			this.RaisePropertyChanged("IsReceivingAll");
		}
Пример #6
0
		private void Initialize(string query = "", List<Tuple<ListId, UserId, string>> listIds = null)
		{
			if (listIds != null && listIds.Any())
			{
				this.SetLists(listIds.Select(key => TwitterClient.Current.Lists.Add(key.Item1, key.Item2, key.Item3)).ToList());
			}

			this.Timeline = new Timeline { SubscribedLists = this.targets };
			this.listener = new PropertyChangedEventListener(this.Timeline)
			{
				(sender, e) => this.RaisePropertyChanged(e.PropertyName),
			};

			this.ChangeFilter(this.CreateFilter(query));
			this._FilterQuery = query;

			this.queryReader
				.Do(q => this.FilterMessage = "")
				.Do(q => this.CanCreateFilter = string.IsNullOrWhiteSpace(q))
				.Throttle(TimeSpan.FromMilliseconds(1000))
				.Select(this.CreateFilter)
				.Where(f => f != null)
				.Do(_ => this.FilterMessage = "フィルターが作成されました。")
				.Do(_ => this.CanCreateFilter = true)
				.Subscribe(f => { });
		}