public static T ListIndexSetOrAdd <T>(this IListOperator list, T t, String name = "") { if (name == null || name == "") { name = "elements"; } List <T> vs = Reflection.ReflectionUtils.FindMemberValue <List <T> >(list, name); if (vs == null) { return(default(T)); } int index = vs.IndexOf(t); T old = default(T); if (index >= 0) { old = vs[index]; vs[index] = t; } else { vs.Add(t); } return(old); }
public static List <T> ListGet <T>(this IListOperator list, String name = "") { if (name == null || name == "") { name = "elements"; } return(Reflection.ReflectionUtils.FindMemberValue <List <T> >(list, name)); }
public static void ListIndexAdd <T>(this IListOperator list, T t, String name = "") { if (name == null || name == "") { name = "elements"; } List <T> vs = Reflection.ReflectionUtils.FindMemberValue <List <T> >(list, name); vs.Add(t); }
public static T ListIndexGet <T>(this IListOperator list, int index, String name = "") { if (name == null || name == "") { name = "elements"; } List <T> vs = Reflection.ReflectionUtils.FindMemberValue <List <T> >(list, name); return(vs == null || vs.Count >= index ? default(T) : vs[index]); }
public static T ListIndexSet <T>(this IListOperator list, int index, T t, String name = "") { if (name == null || name == "") { name = "elements"; } List <T> vs = Reflection.ReflectionUtils.FindMemberValue <List <T> >(list, name); T old = vs == null || vs.Count >= index ? default(T) : vs[index]; if (index < vs.Count) { vs[index] = t; } return(old); }