Esempio n. 1
0
        private static bool ConvertForList(ListDescriptor listDescriptor, ref object data)
        {
            if (ListDescriptor.IsList(data.GetType()))
            {
                if (!TryConvertListData(data, listDescriptor, out data))
                {
                    return(false);
                }
            }
            else
            {
                object convertedData;
                if (!TypeConverterHelper.TryConvert(data, listDescriptor.ElementType, out convertedData))
                {
                    return(false);
                }

                var convertedCollection = Activator.CreateInstance(listDescriptor.Type, true);
                listDescriptor.Add(convertedCollection, convertedData);
                data = convertedCollection;
            }
            return(true);
        }
Esempio n. 2
0
 private static bool HasCollectionReference(Type type)
 {
     return(type.IsArray || ListDescriptor.IsList(type) || DictionaryDescriptor.IsDictionary(type) || SetDescriptor.IsSet(type) || OldCollectionDescriptor.IsCollection(type));
 }