public static bool IsEmbeddedMember(IEntityMetaData metaData, String name)
 {
     String[] nameSplit = EmbeddedMember.Split(name);
     foreach (Member member in metaData.PrimitiveMembers)
     {
         if (!(member is IEmbeddedMember))
         {
             continue;
         }
         if (((IEmbeddedMember)member).GetMemberPathToken()[0].Equals(nameSplit[0]))
         {
             return(true);
         }
     }
     foreach (RelationMember member in metaData.RelationMembers)
     {
         if (!(member is IEmbeddedMember))
         {
             continue;
         }
         if (((IEmbeddedMember)member).GetMemberPathToken()[0].Equals(nameSplit[0]))
         {
             return(true);
         }
     }
     return(false);
 }
        public InitializeEmbeddedMemberVisitor(IClassVisitor cv, IEntityMetaData metaData, String memberPath, IPropertyInfoProvider propertyInfoProvider)
            : base(cv)
        {
            this.metaData        = metaData;
            this.memberPath      = memberPath;
            this.memberPathSplit = memberPath != null?EmbeddedMember.Split(memberPath) : null;

            this.propertyInfoProvider = propertyInfoProvider;
        }
Beispiel #3
0
 public override void VisitEnd()
 {
     String[] memberNameSplit = EmbeddedMember.Split(memberName);
     Member[] memberPath      = new Member[members.Length - 1];
     Array.Copy(members, 0, memberPath, 0, memberPath.Length);
     ImplementGetMemberPath(memberPath);
     ImplementGetMemberPathString(EmbeddedMember.BuildMemberPathString(members));
     ImplementGetMemberPathToken(memberNameSplit);
     ImplementGetChildMember(members[members.Length - 1]);
     base.VisitEnd();
 }
Beispiel #4
0
        protected void FilterWrongRelationMappings(IISet <RelationMember> relationMembers)
        {
            // filter all relations which can not be a relation because of explicit embedded property mapping
            IdentityHashSet <RelationMember> toRemove = new IdentityHashSet <RelationMember>();

            foreach (RelationMember relationMember in relationMembers)
            {
                String[] memberPath = EmbeddedMember.Split(relationMember.Name);
                foreach (RelationMember otherRelationMember in relationMembers)
                {
                    if (Object.ReferenceEquals(relationMember, otherRelationMember) || toRemove.Contains(otherRelationMember))
                    {
                        continue;
                    }
                    if (!(otherRelationMember is IEmbeddedMember))
                    {
                        // only embedded members can help identifying other wrong relation members
                        continue;
                    }
                    String[] otherMemberPath = ((IEmbeddedMember)otherRelationMember).GetMemberPathToken();
                    if (memberPath.Length > otherMemberPath.Length)
                    {
                        continue;
                    }
                    bool match = true;
                    for (int a = 0, size = memberPath.Length; a < size; a++)
                    {
                        if (!memberPath[a].Equals(otherMemberPath[a]))
                        {
                            match = false;
                            break;
                        }
                    }
                    if (match)
                    {
                        toRemove.Add(relationMember);
                        break;
                    }
                }
            }
            relationMembers.RemoveAll(toRemove);
        }
Beispiel #5
0
        public Member GetWidenedMatchingMember(String memberPath)
        {
            Member member = GetMemberByName(memberPath);

            if (member != null)
            {
                // fast case
                return(member);
            }
            String[]      memberPathSplit = EmbeddedMember.Split(memberPath);
            int           length          = memberPathSplit.Length - 1; // the full length has already been tested in the fast case
            StringBuilder sb = new StringBuilder();

            member = GetMemberByName(BuildMemberName(memberPathSplit, length, sb));
            while (member == null && length > 0)
            {
                length--;
                member = GetMemberByName(BuildMemberName(memberPathSplit, length, sb));
            }
            return(member);
        }
        public override IClassVisitor Extend(IClassVisitor visitor, IBytecodeBehaviorState state, IList <IBytecodeBehavior> remainingPendingBehaviors, IList <IBytecodeBehavior> cascadePendingBehaviors)
        {
            MemberEnhancementHint memberHint = state.GetContext <MemberEnhancementHint>();

            if (memberHint == null)
            {
                return(visitor);
            }
            RelationMemberEnhancementHint relationMemberHint = state.GetContext <RelationMemberEnhancementHint>();

            String[] memberNameSplit = EmbeddedMember.Split(memberHint.MemberName);
            if (memberNameSplit.Length == 1)
            {
                IPropertyInfo[] sPropertyPath = new IPropertyInfo[1];
                sPropertyPath[0] = PropertyInfoProvider.GetProperty(memberHint.DeclaringType, memberHint.MemberName);
                visitor          = new EntityMetaDataMemberVisitor(visitor, memberHint.DeclaringType, memberHint.DeclaringType, memberHint.MemberName,
                                                                   EntityMetaDataProvider, sPropertyPath);
                if (relationMemberHint != null)
                {
                    visitor = new EntityMetaDataRelationMemberVisitor(visitor, memberHint.DeclaringType, memberHint.MemberName, sPropertyPath);
                }
                else
                {
                    visitor = new EntityMetaDataPrimitiveMemberVisitor(visitor, memberHint.DeclaringType, memberHint.MemberName, sPropertyPath);
                }
                return(visitor);
            }
            Member[] members  = new Member[memberNameSplit.Length];
            Type     currType = memberHint.DeclaringType;

            IPropertyInfo[] propertyPath = new IPropertyInfo[members.Length];
            StringBuilder   sb           = new StringBuilder();

            for (int a = 0, size = memberNameSplit.Length; a < size; a++)
            {
                if (a + 1 < memberNameSplit.Length)
                {
                    members[a] = MemberTypeProvider.GetMember(currType, memberNameSplit[a]);
                }
                else if (relationMemberHint != null)
                {
                    members[a] = MemberTypeProvider.GetRelationMember(currType, memberNameSplit[a]);
                }
                else
                {
                    members[a] = MemberTypeProvider.GetPrimitiveMember(currType, memberNameSplit[a]);
                }
                if (a > 0)
                {
                    sb.Append('.');
                }
                sb.Append(members[a].Name);
                propertyPath[a] = PropertyInfoProvider.GetProperty(currType, memberNameSplit[a]);
                if (a + 1 < memberNameSplit.Length)
                {
                    currType = BytecodeEnhancer.GetEnhancedType(members[a].RealType,
                                                                new EmbeddedEnhancementHint(memberHint.DeclaringType, currType, sb.ToString()));
                }
                else
                {
                    currType = members[a].RealType;
                }
            }
            visitor = new EntityMetaDataMemberVisitor(visitor, memberHint.DeclaringType, memberHint.DeclaringType, memberHint.MemberName,
                                                      EntityMetaDataProvider, propertyPath);
            if (relationMemberHint != null)
            {
                visitor = new EntityMetaDataRelationMemberVisitor(visitor, memberHint.DeclaringType, memberHint.MemberName, propertyPath);
            }
            else
            {
                visitor = new EntityMetaDataPrimitiveMemberVisitor(visitor, memberHint.DeclaringType, memberHint.MemberName, propertyPath);
            }
            visitor = new EntityMetaDataEmbeddedMemberVisitor(visitor, memberHint.DeclaringType, memberHint.MemberName, members);
            return(visitor);
        }