コード例 #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)));
        }
コード例 #2
0
 /// <summary>
 ///   Gets the type of the collection element.
 /// </summary>
 /// <param name = "classType">Type of the class.</param>
 /// <param name = "member">The member.</param>
 /// <param name = "memberReturnType">Type of the member return.</param>
 /// <returns></returns>
 public Type GetCollectionElementType(Type classType, MemberInfo member, Type memberReturnType)
 {
     return(_profile.GetCollectionElementType(classType, member, memberReturnType));
 }