コード例 #1
0
        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);
        }
コード例 #2
0
 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));
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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]);
        }
コード例 #5
0
        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);
        }