Exemplo n.º 1
0
        protected virtual void ResizeActualValue()
        {
            IList list = actualValue as IList;

            if (children.Count == 0 || (list != null && list.Count == children.Count))
            {
                return;
            }
            list = list ?? EditorReflector.MakeInstance <IList>(declaredType);
            Debug.Assert(list != null, nameof(list) + " != null");
            if (list.Count > children.Count)
            {
                while (list.Count > children.Count)
                {
                    list.RemoveAt(list.Count - 1);
                }
            }
            else if (list.Count < children.Count)
            {
                while (list.Count < children.Count)
                {
                    list.Add(EditorReflector.GetDefaultForType(declaredType.GetGenericArguments()[0]));
                }
            }
            actualValue = list;
        }
Exemplo n.º 2
0
 protected object CreateValue(Type type)
 {
     if (type.IsArray)
     {
         return(Array.CreateInstance(type.GetElementType(), 0));
     }
     return(EditorReflector.MakeInstance(type));
 }