public static Item ToItem(this JObject jobject)这个方法有问题?
yixiaopao opened this issue · 1 comments
yixiaopao commented
public static Item ToItem(this JObject jobject)
{
var json = (JProperty)jobject.First;
switch (json.Name) //?json.value?
{
case nameof(SecsFormat.List): return L(json.Value.Value<JArray>().Values<JObject>().Select(ToItem));
case nameof(SecsFormat.ASCII): return A(json.Value.Value<string>());
case nameof(SecsFormat.JIS8): return J(json.Value.Value<string>());
case nameof(SecsFormat.Binary): return B(json.Value.Values<byte>());
case nameof(SecsFormat.Boolean): return Boolean(json.Value.Values<bool>());
case nameof(SecsFormat.F4): return F4(json.Value.Values<float>());
case nameof(SecsFormat.F8): return F8(json.Value.Values<double>());
case nameof(SecsFormat.I1): return I1(json.Value.Values<sbyte>());
case nameof(SecsFormat.I2): return I2(json.Value.Values<short>());
case nameof(SecsFormat.I4): return I4(json.Value.Values<int>());
case nameof(SecsFormat.I8): return I8(json.Value.Values<long>());
case nameof(SecsFormat.U1): return U1(json.Value.Values<byte>());
case nameof(SecsFormat.U2): return U2(json.Value.Values<ushort>());
case nameof(SecsFormat.U4): return U4(json.Value.Values<uint>());
case nameof(SecsFormat.U8): return U8(json.Value.Values<ulong>());
default: throw new ArgumentOutOfRangeException($"Unknown item format: {json.Name}");
}
}
QinHaifeiCN commented