MsgPack と Json を共用にするための Generics ListTreeNode を 単純な型 JsonNode で置き換え

This commit is contained in:
ousttrue
2021-02-09 15:15:38 +09:00
parent 8c8f39059a
commit c2ffda92dc
38 changed files with 346 additions and 495 deletions

View File

@@ -7,21 +7,19 @@ namespace UniJSON
{
public static class ListTreeNodeArrayExtensions
{
public static IEnumerable<ListTreeNode<T>> ArrayItems<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
public static IEnumerable<JsonNode> ArrayItems(this JsonNode self)
{
if (!self.IsArray()) throw new DeserializationException("is not array");
return self.Children;
}
[Obsolete("Use GetArrayItem(index)")]
public static ListTreeNode<T> GetArrrayItem<T>(this ListTreeNode<T> self, int index)
where T : IListTreeItem, IValue<T>
public static JsonNode GetArrrayItem(this JsonNode self, int index)
{
return GetArrayItem(self, index);
}
public static ListTreeNode<T> GetArrayItem<T>(this ListTreeNode<T> self, int index)
where T : IListTreeItem, IValue<T>
public static JsonNode GetArrayItem(this JsonNode self, int index)
{
int i = 0;
foreach (var v in self.ArrayItems())
@@ -34,15 +32,13 @@ namespace UniJSON
throw new KeyNotFoundException();
}
public static int GetArrayCount<T>(this ListTreeNode<T> self)
where T : IListTreeItem, IValue<T>
public static int GetArrayCount(this JsonNode self)
{
if (!self.IsArray()) throw new DeserializationException("is not array");
return self.Children.Count();
}
public static int IndexOf<T>(this ListTreeNode<T> self, ListTreeNode<T> child)
where T : IListTreeItem, IValue<T>
public static int IndexOf(this JsonNode self, JsonNode child)
{
int i = 0;
foreach (var v in self.ArrayItems())