Esempio n. 1
0
 public static SerializerManager CreateDefault(SerializationTypeRegistry types)
 {
     return(new SerializerManager(
                new List <IConfigureSerializers> {
         new DefaultSerializerSetup()
     },
                Check.NotNull(types, nameof(types))));
 }
Esempio n. 2
0
        public ContractTypeSerializer(SerializationTypeRegistry typeRegistry, ContractTypeSerializerOptions options)
        {
            Check.NotNull(typeRegistry, nameof(typeRegistry));
            Check.NotNull(options, nameof(options));

            JsonSerializerSettings s = options.CloneJsonSettings();

            s.TypeNameHandling      = TypeNameHandling.None;
            s.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
            s.ContractResolver      = new ContractTypeContractResolver(typeRegistry);

            options.Serializers.ConfigureJsonSettings(s);

            _serializer = JsonSerializer.Create(s);
        }
Esempio n. 3
0
        public SerializerManager(IEnumerable <IConfigureSerializers> setups, SerializationTypeRegistry types)
        {
            Check.NotNull(setups, nameof(setups));
            Check.NotNull(types, nameof(types));
            _setups = setups.ToList();

            ContractTypeSerializerOptions contractOptions = new ContractTypeSerializerOptions(
                Serializers,
                new JsonSerializerSettings());

            foreach (IConfigureSerializers setup in setups)
            {
                setup.ConfigureSerializers(Serializers);
                setup.ConfigureContractTypeSerializer(contractOptions.JsonSettings);
            }

            ContractTypeSerializer = new ContractTypeSerializer(types, contractOptions);
        }
Esempio n. 4
0
 public PolymorphicJsonConverter(SerializationTypeRegistry types)
 => _types = Check.NotNull(types, nameof(types));