コード例 #1
0
        private void ConfigureGenerators()
        {
            _typeGenerator             = (StaticJsonSerializerGenerator)_serializationTypeInstance.GetGenerator(_config, _roslynHelper, GetMetadata <StaticJsonSerializerGenerator>());
            _builderGenerator          = (StaticJsonBuilderSerializerGenerator)_serializationTypeInstance.GetBuilderGenerator(_config, _roslynHelper, GetMetadata <StaticJsonSerializerGenerator>());;
            _customSerializerGenerator = (StaticJsonCustomDeserializerGenerator)_serializationTypeInstance.GetCustomSerializerGenerator(_config, _serializerClassFullName, GetMetadata <StaticJsonCustomDeserializerGenerator>());
            _enumsGenerator            = new Enums(_config.SerializersNameSpace, _config.UseTryParseOrDefault, _config.IsMissingFallbackOnEnumsAllowed, GetMetadata <Enums>(), _serializationTypeInstance.PropertyFinder, _fallbackValueOverrides);
            _valueTypeGenerator        = new ValueTypeSerializersGenerator(_config.SerializersNameSpace, _roslynHelper, _config.UseTryParseOrDefault, GetMetadata <ValueTypeSerializersGenerator>());

            _serializerGenerator = new SerializerGenerator(
                _serializerClassFullName,
                new CompositeStaticSerializerResolver(_valueTypeGenerator, _enumsGenerator, _customSerializerGenerator, _builderGenerator, _typeGenerator),
                _collections,
                new JsonCollectionGenerator(_collections),
                _config.IsImmutablesAtRootDisabled,
                _roslynHelper,
                GetMetadata <SerializerGenerator>());
            _moduleGenerator = new ModuleGenerator(_config.SerializersNameSpace, GetMetadata <ModuleGenerator>());
        }
コード例 #2
0
        public override IStaticSerializerResolver GetGenerator(
            SerializerGenerationConfiguration config,
            RoslynMetadataHelper metadataHelper,
            SourceFileMetadata generatedCodeMeta)
        {
            var generator = new StaticJsonSerializerGenerator(
                metadataHelper,
                config.SerializersNameSpace,
                config.DisableToUpperConstructor,
                PropertyFinder,
                PropertyGenerators,
                generatedCodeMeta
                );

            PropertyGenerators.Add(new RecursiveStaticSerializerGenerator(generator));

            return(generator);
        }