bool FilterHit = false,
string RetweetedBy = null,
long? RetweetedId = null,
- StatusGeo Geo = null) :
+ StatusGeo? Geo = null) :
base(Nickname, textFromApi, text, ImageUrl, screenName, createdAt, statusId, IsFav, IsRead,
IsReply, IsExcludeReply, IsProtect, IsOwl, IsMark, InReplyToUser, InReplyToStatusId, Source,
SourceUri, ReplyToList, IsMe, IsDm, userId, FilterHit, RetweetedBy, RetweetedId, Geo)
IsProtect = protect,
IsMark = mark,
InReplyToStatusId = reply ? (long?)100L : null,
- PostGeo = geo ? new PostClass.StatusGeo { Lat = -47.15, Lng = -126.716667 } : null,
+ PostGeo = geo ? new PostClass.StatusGeo(-126.716667, -47.15) : (PostClass.StatusGeo?)null,
};
Assert.Equal(expected, post.StateIndex);
// 既にジオタグが付いているツイートに対しては何もしない
var post = new PostClass
{
- PostGeo = new PostClass.StatusGeo
- {
- Lat = 34.35067978344854,
- Lng = 134.04693603515625,
- },
+ PostGeo = new PostClass.StatusGeo(134.04693603515625, 34.35067978344854),
};
var thumb = await service.GetThumbnailInfoAsync(
{
public class PostClass : ICloneable
{
- public class StatusGeo
+ public struct StatusGeo : IEquatable<StatusGeo>
{
- public double Lng { get; set; }
- public double Lat { get; set; }
+ public double Longitude { get; }
+ public double Latitude { get; }
- public override bool Equals(object obj)
+ public StatusGeo(double longitude, double latitude)
{
- var geo = obj as StatusGeo;
- return geo != null && geo.Lng == this.Lng && geo.Lat == this.Lat;
+ this.Longitude = longitude;
+ this.Latitude = latitude;
}
public override int GetHashCode()
- {
- return this.Lng.GetHashCode() ^ this.Lat.GetHashCode();
- }
+ => this.Longitude.GetHashCode() ^ this.Latitude.GetHashCode();
+
+ public override bool Equals(object obj)
+ => obj is StatusGeo ? this.Equals((StatusGeo)obj) : false;
+
+ public bool Equals(StatusGeo other)
+ => this.Longitude == other.Longitude && this.Latitude == other.Longitude;
+
+ public static bool operator ==(StatusGeo left, StatusGeo right)
+ => left.Equals(right);
+
+ public static bool operator !=(StatusGeo left, StatusGeo right)
+ => !left.Equals(right);
}
public string Nickname { get; set; }
public string TextFromApi { get; set; }
public string RetweetedBy { get; set; }
public long? RetweetedId { get; set; }
private bool _IsDeleted = false;
- private StatusGeo _postGeo = null;
+ private StatusGeo? _postGeo = null;
public int RetweetedCount { get; set; }
public long? RetweetedByUserId { get; set; }
public long? InReplyToUserId { get; set; }
bool FilterHit,
string RetweetedBy,
long? RetweetedId,
- StatusGeo Geo)
+ StatusGeo? Geo)
: this()
{
this.Nickname = Nickname;
}
}
- public StatusGeo PostGeo
+ public StatusGeo? PostGeo
{
get
{
{
var clone = (PostClass)this.MemberwiseClone();
clone.ReplyToList = new List<string>(this.ReplyToList);
- clone.PostGeo = this.PostGeo != null ? new StatusGeo { Lng = this.PostGeo.Lng, Lat = this.PostGeo.Lat } : null;
clone.Media = new List<MediaInfo>(this.Media);
clone.QuoteStatusIds = this.QuoteStatusIds.ToArray();
if (post.PostGeo != null)
{
var map = MapThumb.GetDefaultInstance();
+ var point = post.PostGeo.Value;
thumbnails.Add(new ThumbnailInfo()
{
- ImageUrl = map.CreateMapLinkUrl(post.PostGeo.Lat, post.PostGeo.Lng),
- ThumbnailUrl = map.CreateStaticMapUrl(post.PostGeo.Lat, post.PostGeo.Lng),
+ ImageUrl = map.CreateMapLinkUrl(point.Latitude, point.Longitude),
+ ThumbnailUrl = map.CreateStaticMapUrl(point.Latitude, point.Longitude),
TooltipText = null,
});
}
post.IsFav = tc.Contains(retweeted.Id);
}
- if (retweeted.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = retweeted.Coordinates.Coordinates[0], Lat = retweeted.Coordinates.Coordinates[1] };
+ if (retweeted.Coordinates != null)
+ post.PostGeo = new PostClass.StatusGeo(retweeted.Coordinates.Coordinates[0], retweeted.Coordinates.Coordinates[1]);
//以下、ユーザー情報
var user = retweeted.User;
post.IsFav = tc.Contains(post.StatusId) && TabInformations.GetInstance()[post.StatusId].IsFav;
}
- if (status.Coordinates != null) post.PostGeo = new PostClass.StatusGeo { Lng = status.Coordinates.Coordinates[0], Lat = status.Coordinates.Coordinates[1] };
+ if (status.Coordinates != null)
+ post.PostGeo = new PostClass.StatusGeo(status.Coordinates.Coordinates[0], status.Coordinates.Coordinates[1]);
//以下、ユーザー情報
var user = status.User;