コード例 #1
0
ファイル: MemberTypeProvider.cs プロジェクト: vogelb/ambeth
        protected Member GetMemberIntern(Type type, String propertyName, Type baseType)
        {
            if (propertyName.Contains("&"))
            {
                String[]          compositePropertyNames = propertyName.Split('&');
                PrimitiveMember[] members = new PrimitiveMember[compositePropertyNames.Length];
                for (int a = compositePropertyNames.Length; a-- > 0;)
                {
                    members[a] = (PrimitiveMember)GetMemberIntern(type, compositePropertyNames[a], baseType);
                }
                return(CompositeIdFactory.CreateCompositeIdMember(type, members));
            }
            Type enhancedType = GetMemberTypeIntern(type, propertyName, baseType);

            if (enhancedType == baseType)
            {
                throw new Exception("Must never happen. No enhancement for " + baseType + " has been done");
            }
            ConstructorInfo constructor = enhancedType.GetConstructor(Type.EmptyTypes);

            return((Member)constructor.Invoke(EMPTY_OBJECTS));
        }
コード例 #2
0
ファイル: EntityMetaDataReader.cs プロジェクト: vogelb/ambeth
        protected PrimitiveMember HandleMemberConfig(IEntityMetaData metaData, Type realType, IMemberConfig memberConfig,
                                                     IMap <String, Member> explicitMemberNameToMember, IMap <String, Member> allMemberNameToMember)
        {
            if (memberConfig == null)
            {
                return(null);
            }
            if (!(memberConfig is CompositeMemberConfig))
            {
                PrimitiveMember member = HandleMemberConfigIfNew(realType, memberConfig.Name, explicitMemberNameToMember);
                explicitMemberNameToMember.Put(memberConfig.Name, member);
                ((IPrimitiveMemberWrite)member).SetTransient(memberConfig.Transient);

                PrimitiveMember definedBy = memberConfig.DefinedBy != null?HandleMemberConfigIfNew(realType, memberConfig.DefinedBy,
                                                                                                   allMemberNameToMember) : null;

                ((IPrimitiveMemberWrite)member).SetDefinedBy(definedBy);
                return(member);
            }
            MemberConfig[]    memberConfigs = ((CompositeMemberConfig)memberConfig).GetMembers();
            PrimitiveMember[] members       = new PrimitiveMember[memberConfigs.Length];
            for (int a = memberConfigs.Length; a-- > 0;)
            {
                MemberConfig    memberPart = memberConfigs[a];
                PrimitiveMember member     = HandleMemberConfigIfNew(realType, memberPart.Name, explicitMemberNameToMember);
                members[a] = member;
            }
            PrimitiveMember compositeIdMember = CompositeIdFactory.CreateCompositeIdMember(metaData, members);

            explicitMemberNameToMember.Put(memberConfig.Name, compositeIdMember);
            ((IPrimitiveMemberWrite)compositeIdMember).SetTransient(memberConfig.Transient);

            PrimitiveMember definedBy2 = memberConfig.DefinedBy != null?HandleMemberConfigIfNew(realType, memberConfig.DefinedBy, allMemberNameToMember)
                                             : null;

            ((IPrimitiveMemberWrite)compositeIdMember).SetDefinedBy(definedBy2);
            return(compositeIdMember);
        }