Ejemplo n.º 1
0
        protected override ISerializer Create(TypeInfo parameter)
        {
            var converter = _converters.Get(parameter);
            var result    = converter != null ? new Serializer(_readers.Get(converter.Parse), _writers.Get(converter.Format)) : _fallback.Get(parameter);

            return(result);
        }
        IConverter From(MemberDescriptor descriptor)
        {
            var result = _converters.Get(descriptor.MemberType);

            if (result != null)
            {
                return(result);
            }
            throw new InvalidOperationException(
                      $"An attempt was made to format '{descriptor.Metadata}' as an attribute, but there is not a registered converter that can convert its values to a string.  Please ensure a converter is registered for the type '{descriptor.MemberType}' by adding a converter for this type to the converter collection in the ConverterExtension.");
        }
Ejemplo n.º 3
0
            public ISerializer Get(TypeInfo parameter)
            {
                var underlying = Nullable.GetUnderlyingType(parameter);

                if (underlying != null)
                {
                    var serializer = _previous.Get(_converters.Get(parameter) != null ? parameter : underlying);
                    return(new Serializer(new Reader(serializer), serializer));
                }

                return(_previous.Get(parameter));
            }
            IMemberSerializer Create(IMemberSerializer serializer, Type owner)
            {
                var item     = CollectionItemTypeLocator.Default.Get(serializer.Profile.MemberType);
                var itemType = _member.Get(owner)
                               .Item1;
                var member = (IMemberSerializer) new MemberSerializer(serializer, _converters.Get(itemType));
                var result = item != null
                                                     ? new ListSerializer(_serializer, _serializers, serializer, member,
                                                                          _identities.Get(owner), item)
                                                     : member;

                return(result);
            }
Ejemplo n.º 5
0
 public IConverter Get(TypeInfo parameter) => _converters.Get(parameter)
 .Alter(_alteration.Get);