--
You received this message because you are subscribed to the Google Groups "Jayrock" group.
To post to this group, send email to jay...@googlegroups.com.
To unsubscribe from this group, send email to jayrock+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jayrock?hl=en.
Can you please tell me what's the best way to set the MaxDepth property in my software?
To unsubscribe from this group, send email to jayrock+u...@googlegroups.com.
- Atif
> To unsubscribe from this group, send email to jayrock+u...@googlegroups.com.
To unsubscribe from this group, send email to jayrock+u...@googlegroups.com.
Aziz, thanks again for your hardwork on Jayrock. Couple of things we have picked up – we made the following changes to the importer code to make it work correctly with List<T>:
static IImporter FindCompatibleImporter(Type type)
{
Debug.Assert(type != null);
if (typeof(IJsonImportable).IsAssignableFrom(type))
return new ImportAwareImporter(type);
if (type.IsArray && type.GetArrayRank() == 1)
return new ArrayImporter(type);
if (type.IsEnum)
return new EnumImporter(type);
#if !NET_1_0 && !NET_1_1
if (Reflector.IsConstructionOfNullable(type))
return new NullableImporter(type);
bool isGenericList = Reflector.IsConstructionOfGenericTypeDefinition(type, typeof(IList<>));
bool isGenericCollection = !isGenericList && Reflector.IsConstructionOfGenericTypeDefinition(type, typeof(ICollection<>));
bool isSequence = (!isGenericCollection && !isGenericList) && (type == typeof(IEnumerable) || Reflector.IsConstructionOfGenericTypeDefinition(type, typeof(IEnumerable<>)));
also in the reflector class:
internal static bool IsConstructionOfGenericTypeDefinition(Type type, Type genericTypeDefinition)
{
if (type == null) throw new ArgumentNullException("type");
if (genericTypeDefinition == null) throw new ArgumentNullException("genericTypeDefinition");
if (!genericTypeDefinition.IsGenericTypeDefinition)
throw new ArgumentException(string.Format("{0} is not a generic type definition.", genericTypeDefinition), "genericTypeDefinition");
while (type != null && type != typeof(object))
{
Type cur = type.IsGenericType ? type.GetGenericTypeDefinition() : type;
if (genericTypeDefinition == cur || Array.Find(cur.GetInterfaces(), delegate(Type t) { return (t.IsGenericType ? t.GetGenericTypeDefinition() : t) == genericTypeDefinition; }) != null)
{
return true;
}
type = type.BaseType;
}
return false;
}