4 using System.Collections.Generic;
5 using System.Reflection;
7 namespace SiliconStudio.Core.Reflection
14 private readonly Type elementType;
15 private readonly Type listType;
16 private readonly MethodInfo toArrayMethod;
27 if (!type.IsArray)
throw new ArgumentException(
"Expecting array type",
"type");
29 if (type.GetArrayRank() != 1)
31 throw new ArgumentException(
"Cannot support dimension [{0}] for type [{1}]. Only supporting dimension of 1".ToFormat(type.GetArrayRank(), type.FullName));
34 Category = DescriptorCategory.Array;
35 elementType = type.GetElementType();
36 listType = typeof(List<>).MakeGenericType(ElementType);
37 toArrayMethod = listType.GetMethod(
"ToArray");
44 public Type ElementType
58 return Array.CreateInstance(ElementType, dimension);
Default implementation of a ITypeDescriptor.
ArrayDescriptor(ITypeDescriptorFactory factory, Type type)
Initializes a new instance of the ObjectDescriptor class.
A descriptor for an array.
A factory to create an instance of a ITypeDescriptor
Array CreateArray(int dimension)
Creates the equivalent of list type for this array.