protected virtual Boolean IsOneToMany(MemberInfo member, Boolean isLikely) { Type sourceType = member.DeclaringType; Type destinationType = member.GetMemberFromDeclaringType().GetPropertyOrFieldType(); //check if the property is of a generic collection type if ((destinationType.IsGenericCollection() == true) && (destinationType.GetGenericArguments().Length == 1)) { Type destinationEntityType = destinationType.GetGenericArguments().Single(); //check if the type of the generic collection property is an entity if (this.ModelInspector.IsEntity(destinationEntityType) == true) { //check if there is an equivalent property on the target type that is also a generic collection and points to this entity PropertyInfo collectionInDestinationType = destinationEntityType.GetProperties().Where(x => (x.PropertyType.IsGenericCollection() == true) && (x.PropertyType.GetGenericArguments().Length == 1) && (x.PropertyType.GetGenericArguments().Single() == sourceType)).SingleOrDefault(); if (collectionInDestinationType != null) { return (false); } } } return (true); }
public static bool ContainsMember(this ICollection<MemberInfo> source, MemberInfo item) { return source.Count > 0 && (source.Contains(item) || (!item.DeclaringType.Equals(item.ReflectedType) && source.Contains(item.GetMemberFromDeclaringType())) || item.GetPropertyFromInterfaces().Any(source.Contains)); }
public string GetSplitGroupFor(MemberInfo member) { var memberKey = member.GetMemberFromDeclaringType(); string splitGroup; if (memberSplitGroup.TryGetValue(memberKey, out splitGroup)) { return splitGroup; } return null; }