public static bool IsRepeatMapping(this IBasicMapperData mapperData) { if (mapperData.IsRoot || (mapperData.TargetMember.Depth == 2)) { return(false); } if (mapperData.TargetMember.IsRecursion) { return(true); } if ((mapperData.TargetMember.Depth == 3) && mapperData.TargetMemberIsEnumerableElement()) { return(false); } if (TargetMemberHasRecursiveObjectGraph(mapperData.TargetMember) == false) { return(false); } // The target member we're mapping right now isn't recursive, but it has recursion // within its child members, and its mapping might be repeated elsewhere within the // mapping graph. We therefore check if this member ever repeats; if so we'll map it // by calling MapRepeated, and it'll be the entry point of the RepeatedMapperFunc // which performs the repeated mapping: var rootMember = mapperData.GetRootMapperData().TargetMember; return(TargetMemberEverRepeatsWithin(rootMember, mapperData.TargetMember)); }
public static bool IsRepeatMapping(this IBasicMapperData mapperData) { if (mapperData.IsRoot || (mapperData.TargetMember.Depth == 2)) { return(false); } if (mapperData.TargetMember.IsRecursion) { return(true); } if ((mapperData.TargetMember.Depth == 3) && mapperData.TargetMemberIsEnumerableElement()) { return(false); } if (GetTargetMembers(mapperData.TargetType).All(tm => tm.IsSimple)) { return(false); } // The target member we're mapping right now isn't recursive, but // it might recurse elsewhere within the mapping graph. // We therefore check if this member ever recurses; if so we'll // map it by calling MapRepeated, and it'll be the entry point of // the RepeatedMapperFunc which performs the repeated mapping: var rootMember = mapperData.GetRootMapperData().TargetMember; return(TargetMemberEverRecursesWithin(rootMember, mapperData.TargetMember)); }