Esempio n. 1
0
 public Enums(string @namespace, bool useTryParseOrDefault, bool isMissingFallbackAllowed, SourceFileMetadata meta, IPropertyFinder codeAnalyzer, Dictionary <ITypeSymbol, TypedConstant> fallbackValueOverrides)
 {
     _nameSpace                = @namespace;
     _useTryParseOrDefault     = useTryParseOrDefault;
     _isMissingFallbackAllowed = isMissingFallbackAllowed;
     _meta                   = meta;
     _codeAnalyzer           = codeAnalyzer;
     _fallbackValueOverrides = fallbackValueOverrides;
 }
Esempio n. 2
0
        public ValueTypeSerializersGenerator(string nameSpace, RoslynMetadataHelper roselyn, bool useTryParseOrDefault, SourceFileMetadata generatedCodeMeta)
        {
            _nameSpace         = nameSpace;
            _generatedCodeMeta = generatedCodeMeta;
            _context           = new GeneratorContext(
                roselyn,
                new ReadContext("reader", "firstChar", "overChar"),
                new WriteContext("writer"),
                new DateTimeGenerator(useTryParseOrDefault),
                new JsonReaderGenerator(useTryParseOrDefault),
                new JsonWriterGenerator());

            _typeSymbols = Types
                           .Select(roselyn.GetTypeByFullName)
                           .ToArray();
        }
 public SerializerGenerator(
     string classFullName,
     IStaticSerializerResolver staticSerializerResolver,
     ICollectionImplementationResolver supportedCollections,
     IValueSerializationGenerator valuesGenerator,
     bool isRootImmutableDisabled,
     RoslynMetadataHelper roslyn,
     SourceFileMetadata generatedCodeMeta)
 {
     _classFullName            = classFullName;
     _staticSerializerResolver = staticSerializerResolver;
     _supportedCollections     = supportedCollections;
     _valuesGenerator          = valuesGenerator;
     _isRootImmutableDisabled  = isRootImmutableDisabled;
     _roslyn            = roslyn;
     _generatedCodeMeta = generatedCodeMeta;
 }
        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);
        }
Esempio n. 5
0
 public StaticJsonBuilderSerializerGenerator(
     RoslynMetadataHelper metadataHelper,
     string @namespace,
     bool disableToUpperCtor,
     IPropertyFinder propertyFinder,
     IEnumerable <IValueSerializationGenerator> valueGenerators,
     SourceFileMetadata generatedCodeMeta)
 {
     _metadataHelper     = metadataHelper;
     _namespace          = @namespace;
     _disableToUpperCtor = disableToUpperCtor;
     _propertyFinder     = propertyFinder;
     _valueGenerators    = valueGenerators;
     _generatedCodeMeta  = generatedCodeMeta;
     _propertyGenerator  = () => new GeneratorContext(
         _metadataHelper,
         new ReadContext(SerializerConstants.ReaderParameterName, _overChar),
         new WriteContext(_writer, _object),
         valueGenerators.ToArray()
         );
 }
 public ModuleGenerator(string @namespace, SourceFileMetadata generatedCodeMeta)
 {
     _namespace         = @namespace;
     _generatedCodeMeta = generatedCodeMeta;
 }
Esempio n. 7
0
 public StaticJsonCustomDeserializerGenerator(string @namespace, SourceFileMetadata generatedCodeMeta, string serializerProviderFullName)
 {
     _namespace                  = @namespace;
     _generatedCodeMeta          = generatedCodeMeta;
     _serializerProviderFullName = serializerProviderFullName;
 }
 public abstract ISerializerGenerator GetCustomSerializerGenerator(SerializerGenerationConfiguration config, string serializerProviderFullName, SourceFileMetadata metadata);
 public abstract IStaticSerializerResolver GetBuilderGenerator(SerializerGenerationConfiguration config, RoslynMetadataHelper metadataHelper, SourceFileMetadata metadata);
        public override ISerializerGenerator GetCustomSerializerGenerator(SerializerGenerationConfiguration config, string serializerProviderFullName, SourceFileMetadata generatedCodeMeta)
        {
            var generator = new StaticJsonCustomDeserializerGenerator(
                config.SerializersNameSpace,
                generatedCodeMeta,
                serializerProviderFullName
                );

            PropertyGenerators.Add(new RecursiveStaticSerializerGenerator(generator));

            return(generator);
        }