Пример #1
0
        public IntermediateRelationMember GetIntermediateRelationMember(Type entityType, String propertyName)
        {
            String[] memberNamePath    = EmbeddedMember.Split(propertyName);
            Type     currDeclaringType = entityType;

            Member[] members = new Member[memberNamePath.Length];
            for (int a = 0, size = memberNamePath.Length; a < size; a++)
            {
                IPropertyInfo property = PropertyInfoProvider.GetProperty(currDeclaringType, memberNamePath[a]);
                if (property == null)
                {
                    return(null);
                }
                members[a] = new IntermediateRelationMember(currDeclaringType, entityType, property.PropertyType, property.ElementType,
                                                            property.Name, property.GetAnnotations());
                currDeclaringType = property.PropertyType;
            }
            if (members.Length > 1)
            {
                Member[] memberPath = new Member[members.Length - 1];
                Array.Copy(members, 0, memberPath, 0, memberPath.Length);
                Member lastMember = members[memberPath.Length];
                return(new IntermediateEmbeddedRelationMember(entityType, lastMember.RealType, lastMember.ElementType, propertyName, memberPath,
                                                              lastMember));
            }
            return((IntermediateRelationMember)members[0]);
        }
Пример #2
0
        public static IPropertyInfo[] BuildPropertyPath(Type entityType, String memberName, IPropertyInfoProvider propertyInfoProvider)
        {
            String[] memberPath = EmbeddedMember.Split(memberName);
            Type     currType   = entityType;

            IPropertyInfo[] propertyPath = new IPropertyInfo[memberPath.Length];
            for (int a = 0, size = propertyPath.Length; a < size; a++)
            {
                IPropertyInfo property = propertyInfoProvider.GetProperty(currType, memberPath[a]);
                if (property == null)
                {
                    FieldInfo[] fields = ReflectUtil.GetDeclaredFieldInHierarchy(currType, memberPath[a]);
                    if (fields.Length == 0)
                    {
                        throw new Exception("Path illegal: " + memberName);
                    }
                    property = new FieldPropertyInfo(currType, memberPath[a], fields[a]);
                }
                propertyPath[a] = property;
                currType        = property.PropertyType;
            }
            return(propertyPath);
        }