コード整理、UniGLTF/Runtime, Editor, Tests

This commit is contained in:
ousttrue
2020-12-01 17:10:13 +09:00
parent 32ec9beb1f
commit f7f6730fec
402 changed files with 24 additions and 118 deletions

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace UniJSON
{
public static class ListTreeNodeArrayExtensions
{
public static IEnumerable<ListTreeNode<T>> ArrayItems<T>(this ListTreeNode<T> self) where T : IListTreeItem, IValue<T>
{
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>
{
return GetArrayItem(self, index);
}
public static ListTreeNode<T> GetArrayItem<T>(this ListTreeNode<T> self, int index)
where T : IListTreeItem, IValue<T>
{
int i = 0;
foreach (var v in self.ArrayItems())
{
if (i++ == index)
{
return v;
}
}
throw new KeyNotFoundException();
}
public static int GetArrayCount<T>(this ListTreeNode<T> self)
where T : IListTreeItem, IValue<T>
{
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>
{
int i = 0;
foreach (var v in self.ArrayItems())
{
if (v.ValueIndex == child.ValueIndex)
{
return i;
}
++i;
}
throw new KeyNotFoundException();
}
}
}