public IMemberConfiguration GetMemberConfigurationType(string memberName, MemberTypes memberType,
                                                               TypeResolvingConfiguration typeResolvingConfiguration)
        {
            if (!_memberTypeSupportConsultant.IsMemberTypeSupported(memberType))
            {
                throw new NotSupportedException("can't get configuration for member that type is not supported");
            }

            return(_memberTypesConfigurationsAccessorsMapping[memberType]
                   .Invoke(typeResolvingConfiguration, memberName));
        }
        public bool HasMemberConfigurationType(string memberName, MemberTypes memberType,
                                               TypeResolvingConfiguration typeResolvingConfiguration)
        {
            if (!_memberTypeSupportConsultant.IsMemberTypeSupported(memberType))
            {
                throw new NotSupportedException("can't determine existence of configuration for member that type is not supported");
            }

            return(_memberTypesConfigurationsExistenceHandlersMapping[memberType]
                   .Invoke(typeResolvingConfiguration, memberName));
        }
        /// <inheritdoc />
        void IMemberConfigurationHandler.HandleMemberConfiguration(MemberInfo member, JsonProperty property, TypeResolvingConfiguration configuration)
        {
            if (_memberConfigurationAccessController.HasMemberConfigurationType(member.Name,
                                                                                member.MemberType,
                                                                                configuration))
            {
                var memberConfiguration = _memberConfigurationAccessController.GetMemberConfigurationType(member.Name,
                                                                                                          member.MemberType,
                                                                                                          configuration);
                property.PropertyName = memberConfiguration.JsonBinding;
                if (memberConfiguration.Ignored)
                {
                    // PropertyName cannot be null
                    property.Ignored      = true;
                    property.PropertyName = string.Empty;
                }

                HandleMemberConfiguration(member, property, memberConfiguration as TMemberConfiguration);
            }
        }
Пример #4
0
 public TypeResolvingConfigurationBuilder(TypeResolvingConfiguration configuration)
 {
     Configuration = configuration;
 }
        public IMemberConfiguration CreateMemberConfigurationForType(string memberName, MemberTypes memberType, TypeResolvingConfiguration typeResolvingConfiguration)
        {
            if (!_memberTypeSupportConsultant.IsMemberTypeSupported(memberType))
            {
                throw new NotSupportedException("can't create configuration for member that type is not supported");
            }

            return(_memberTypesConfigurationsFactoriesMapping[memberType]
                   .Invoke(typeResolvingConfiguration, memberName));
        }