// Boston, MA 02110-1301, USA.
using System.Collections.Generic;
+using System.Threading.Tasks;
using System.Xml.Serialization;
+using OpenTween.Api.DataModel;
namespace OpenTween
{
public string Username = "";
public string Nickname = "";
- protected dynamic _tw;
+ protected Twitter _tw;
private List<UserInfo> _members = null;
- private long _cursor = -1;
+
+ [XmlIgnore]
+ public long Cursor { get; private set; } = -1;
public ListElement()
{
}
- public ListElement(TwitterDataModel.ListElementData listElementData, dynamic tw)
+ public ListElement(TwitterList listElementData, Twitter tw)
{
this.Description = listElementData.Description;
this.Id = listElementData.Id;
this._tw = tw;
}
- public virtual string Refresh()
+ public virtual async Task Refresh()
{
- ListElement t = this;
- return _tw.EditList(this.Id.ToString(), Name, !this.IsPublic, this.Description, ref t);
+ var newList = await _tw.EditList(this.Id, Name, !this.IsPublic, this.Description)
+ .ConfigureAwait(false);
+
+ this.Description = newList.Description;
+ this.Id = newList.Id;
+ this.IsPublic = newList.IsPublic;
+ this.MemberCount = newList.MemberCount;
+ this.Name = newList.Name;
+ this.SubscriberCount = newList.SubscriberCount;
+ this.Slug = newList.Slug;
+ this.Nickname = newList.Nickname;
+ this.Username = newList.Username;
+ this.UserId = newList.UserId;
}
[XmlIgnore]
}
}
- [XmlIgnore]
- public long Cursor
- {
- get
- {
- return _cursor;
- }
- }
-
- public string RefreshMembers()
+ public async Task RefreshMembers()
{
var users = new List<UserInfo>();
- _cursor = -1;
- var result = this._tw.GetListMembers(this.Id.ToString(), users, ref _cursor);
+ this.Cursor = await this._tw.GetListMembers(this.Id, users, cursor: -1)
+ .ConfigureAwait(false);
this._members = users;
- return string.IsNullOrEmpty(result) ? this.ToString() : result;
}
- public string GetMoreMembers()
+ public async Task GetMoreMembers()
{
- var result = this._tw.GetListMembers(this.Id.ToString(), this._members, ref _cursor);
- return string.IsNullOrEmpty(result) ? this.ToString() : result;
+ this.Cursor = await this._tw.GetListMembers(this.Id, this._members, this.Cursor)
+ .ConfigureAwait(false);
}
public override string ToString()