Light12306/TrainInfomationProviderService/TrainInfo/Entities/TrainStop.cs
2014-11-27 23:25:36 +08:00

61 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using TrainInfomationProviderService.StationInfo;
namespace TrainInfomationProviderService.TrainInfo.Entities
{
public class TrainStop
{
private string _name;
[JsonProperty("c")]
public string Code { get; set; }
[JsonProperty("i")]
public int Index { get; set; }
[JsonProperty("a")]
public TimeSpan? Arrive { get; set; }
[JsonProperty("l")]
public TimeSpan? Left { get; set; }
[JsonProperty("d")]
public int Days { get; set; }
/// <summary>
/// 停靠时间
/// </summary>
[JsonIgnore]
public TimeSpan StopTime
{
get
{
if (Arrive == null || Left == null)
return TimeSpan.MaxValue;
return Left.Value - Arrive.Value;
}
}
[JsonIgnore]
public string Name
{
get
{
if (string.IsNullOrEmpty(_name) && StationManager.Instance.Storage != null)
{
if (!string.IsNullOrEmpty(Code))
_name = StationManager.Instance.Storage.Stations.GetValue(Code).SelectValue(s => s.Name);
else _name = string.Empty;
}
return _name;
}
}
}
}