Exemplo n.º 1
0
        /// <summary>
        /// Gets the type of the inner list of a IList&gt;IList&lt;
        /// </summary>
        /// <param name="list">The list.</param>
        /// <returns>
        /// The type of the inner list. Return <c>null</c> if only interface type can be retrieved.
        /// </returns>
        public static Type GetInnerTypeOfList(IList list)
        {
            var innerType = TypeHelper.GetInnerMostGenericType(list);

            if (innerType != null && innerType.IsInterface)
            {
                if (list.Count > 0)
                {
                    var row = list[0] as IList;
                    if (row != null && row.Count > 0)
                    {
                        // Get the type from the [0][0]. The assumption is all the elements in the ItemsSource are of the same type.
                        innerType = row[0].GetType();
                    }
                }
                else
                {
                    innerType = null;
                }
            }

            return(innerType);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets the item type.
 /// </summary>
 /// <returns>
 /// The type of the elements in the list.
 /// </returns>
 public override Type GetItemsType()
 {
     return(TypeHelper.GetInnerMostGenericType(this.ItemsSource));
 }