2023-06-01 13:56:34 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
// <auto-generated />
|
|
|
|
|
//
|
|
|
|
|
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
|
|
|
|
|
//
|
|
|
|
|
// using QuickType;
|
|
|
|
|
//
|
|
|
|
|
// var welcome = Welcome.FromJson(jsonString);
|
|
|
|
|
|
|
|
|
|
namespace TyphoonApi
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
|
|
|
|
|
|
public partial class Welcome
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("?xml")]
|
|
|
|
|
public Xml Xml { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("alert")]
|
|
|
|
|
public Alert Alert { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class Alert
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("@xmlns")]
|
|
|
|
|
public string Xmlns { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("identifier")]
|
|
|
|
|
public string Identifier { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("sender")]
|
|
|
|
|
public string Sender { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("sent")]
|
|
|
|
|
public DateTimeOffset Sent { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("status")]
|
|
|
|
|
public string Status { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("msgType")]
|
|
|
|
|
public string MsgType { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("scope")]
|
|
|
|
|
public string Scope { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("references")]
|
|
|
|
|
public string References { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("info")]
|
|
|
|
|
public Info Info { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class Info
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("language")]
|
|
|
|
|
public string Language { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("category")]
|
|
|
|
|
public string Category { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("event")]
|
|
|
|
|
public string Event { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("urgency")]
|
|
|
|
|
public string Urgency { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("severity")]
|
|
|
|
|
public string Severity { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("certainty")]
|
|
|
|
|
public string Certainty { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("eventCode")]
|
|
|
|
|
public EventCode EventCode { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("effective")]
|
|
|
|
|
public DateTimeOffset Effective { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("onset")]
|
|
|
|
|
public DateTimeOffset Onset { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("expires")]
|
|
|
|
|
public DateTimeOffset Expires { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("senderName")]
|
|
|
|
|
public string SenderName { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("headline")]
|
|
|
|
|
public string Headline { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("description")]
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public string Description { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("instruction")]
|
|
|
|
|
public string Instruction { get; set; }
|
2023-06-01 13:56:34 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty("web")]
|
|
|
|
|
public Uri Web { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("parameter")]
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public EventCode Parameter { get; set; }
|
2023-06-01 13:56:34 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty("area")]
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public List<Area> Area { get; set; }
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class Area
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("areaDesc")]
|
|
|
|
|
public string AreaDesc { get; set; }
|
|
|
|
|
|
2023-06-01 16:43:39 +08:00
|
|
|
|
[JsonProperty("geocode")]
|
|
|
|
|
public EventCode Geocode { get; set; }
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class EventCode
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("valueName")]
|
|
|
|
|
public string ValueName { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("value")]
|
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partial class Xml
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty("@version")]
|
|
|
|
|
public string Version { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonProperty("@encoding")]
|
|
|
|
|
public string Encoding { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public enum ValueName { AlertTitle, ProfileCapTwpEvent10, TaiwanGeocode103 };
|
|
|
|
|
|
2023-06-01 13:56:34 +08:00
|
|
|
|
public partial class Welcome
|
|
|
|
|
{
|
|
|
|
|
public static Welcome FromJson(string json) => JsonConvert.DeserializeObject<Welcome>(json, QuickType.Converter.Settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Serialize
|
|
|
|
|
{
|
|
|
|
|
public static string ToJson(this Welcome self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal static class Converter
|
|
|
|
|
{
|
|
|
|
|
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
|
|
|
|
{
|
|
|
|
|
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
|
|
|
|
DateParseHandling = DateParseHandling.None,
|
|
|
|
|
Converters =
|
|
|
|
|
{
|
2023-06-01 16:43:39 +08:00
|
|
|
|
ValueNameConverter.Singleton,
|
2023-06-01 13:56:34 +08:00
|
|
|
|
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 16:43:39 +08:00
|
|
|
|
internal class ValueNameConverter : JsonConverter
|
2023-06-01 13:56:34 +08:00
|
|
|
|
{
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public override bool CanConvert(Type t) => t == typeof(ValueName) || t == typeof(ValueName?);
|
2023-06-01 13:56:34 +08:00
|
|
|
|
|
|
|
|
|
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
|
|
|
|
|
{
|
|
|
|
|
if (reader.TokenType == JsonToken.Null) return null;
|
|
|
|
|
var value = serializer.Deserialize<string>(reader);
|
2023-06-01 16:43:39 +08:00
|
|
|
|
switch (value)
|
2023-06-01 13:56:34 +08:00
|
|
|
|
{
|
2023-06-01 16:43:39 +08:00
|
|
|
|
case "Taiwan_Geocode_103":
|
|
|
|
|
return ValueName.TaiwanGeocode103;
|
|
|
|
|
case "alert_title":
|
|
|
|
|
return ValueName.AlertTitle;
|
|
|
|
|
case "profile:CAP-TWP:Event:1.0":
|
|
|
|
|
return ValueName.ProfileCapTwpEvent10;
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
2023-06-01 16:43:39 +08:00
|
|
|
|
throw new Exception("Cannot unmarshal type ValueName");
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
|
|
|
|
|
{
|
|
|
|
|
if (untypedValue == null)
|
|
|
|
|
{
|
|
|
|
|
serializer.Serialize(writer, null);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-06-01 16:43:39 +08:00
|
|
|
|
var value = (ValueName)untypedValue;
|
|
|
|
|
switch (value)
|
|
|
|
|
{
|
|
|
|
|
case ValueName.TaiwanGeocode103:
|
|
|
|
|
serializer.Serialize(writer, "Taiwan_Geocode_103");
|
|
|
|
|
return;
|
|
|
|
|
case ValueName.AlertTitle:
|
|
|
|
|
serializer.Serialize(writer, "alert_title");
|
|
|
|
|
return;
|
|
|
|
|
case ValueName.ProfileCapTwpEvent10:
|
|
|
|
|
serializer.Serialize(writer, "profile:CAP-TWP:Event:1.0");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw new Exception("Cannot marshal type ValueName");
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-01 16:43:39 +08:00
|
|
|
|
public static readonly ValueNameConverter Singleton = new ValueNameConverter();
|
2023-06-01 13:56:34 +08:00
|
|
|
|
}
|
|
|
|
|
}
|