示例#1
0
        private PersistentMemberMap CreateMemberMap(Type classType, MemberInfo member)
        {
            var memberReturnType = member.GetReturnType();

            var dictionaryAdapter = _profile.GetDictionaryAdapter(classType, member, memberReturnType);

            if (dictionaryAdapter != null)
            {
                return(new DictionaryMemberMap(
                           member.Name,
                           MemberReflectionOptimizer.GetGetter(member),
                           MemberReflectionOptimizer.GetSetter(member),
                           _profile.GetAlias(classType, member),
                           _profile.GetPersistDefaultValue(classType, member),
                           dictionaryAdapter));
            }

            var collectionType = _profile.GetCollectionAdapter(classType, member, memberReturnType);

            if (collectionType != null)
            {
                return(new CollectionMemberMap(
                           member.Name,
                           memberReturnType,
                           MemberReflectionOptimizer.GetGetter(member),
                           MemberReflectionOptimizer.GetSetter(member),
                           _profile.GetAlias(classType, member),
                           _profile.GetPersistDefaultValue(classType, member),
                           collectionType,
                           _profile.GetCollectionElementType(classType, member, memberReturnType)));
            }

            //TODO: reference checking...

            return(new PersistentMemberMap(
                       member.Name,
                       memberReturnType,
                       MemberReflectionOptimizer.GetGetter(member),
                       MemberReflectionOptimizer.GetSetter(member),
                       _profile.GetDefaultValue(classType, member),
                       _profile.GetAlias(classType, member),
                       _profile.GetPersistDefaultValue(classType, member)));
        }
        /// <summary>
        ///   Gets the property name for the member.
        /// </summary>
        /// <param name = "classType">Type of the entity.</param>
        /// <param name = "member">The member.</param>
        /// <returns></returns>
        public string GetAlias(Type classType, MemberInfo member)
        {
            var alias = _profile.GetAlias(classType, member);

            return(GetMemberOverrideValue(classType,
                                          member,
                                          o => o.Alias,
                                          s => !string.IsNullOrEmpty(s),
                                          alias));
        }