/// <summary>
        ///   Gets the default value.
        /// </summary>
        /// <param name = "classType">Type of the class.</param>
        /// <param name = "member">The member.</param>
        /// <returns></returns>
        public object GetDefaultValue(Type classType, MemberInfo member)
        {
            var defaultValue = _profile.GetDefaultValue(classType, member);

            return(GetMemberOverrideValue(classType,
                                          member,
                                          o => o.DefaultValue,
                                          v => v != null,
                                          defaultValue));
        }
Пример #2
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)));
        }