Exemple #1
0
        /// <inheritdoc />
        public void Execute(GeneratorExecutionContext context)
        {
            try
            {
                var options = SourceGenerationOptions.From(context);

                var compilation = context.Compilation
                                  .AddSource(ref context, MapFromAttributeSource.Generate(options))
                                  .AddSource(ref context, IgnorePropertyAttributeSource.Generate(options))
                                  .AddSource(ref context, ITypeConverterSource.Generate(options))
                                  .AddSource(ref context, MapTypeConverterAttributeSource.Generate(options))
                                  .AddSource(ref context, MapPropertyAttributeSource.Generate(options))
                                  .AddSource(ref context, MappingContextSource.Generate(options));

                if (context.SyntaxReceiver is MapToSyntaxReceiver receiver && receiver.CandidateTypes.Any())
                {
                    AddGeneratedMappingsClasses(context, compilation, receiver.CandidateTypes, options);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }
        }
Exemple #2
0
        public SourcedTypeConverter(ITypeConverterSource typeConverterSource)
        {
            if (typeConverterSource == null)
            {
                throw new ArgumentNullException(nameof(typeConverterSource));
            }

            this.typeConverterSource = typeConverterSource;
        }
Exemple #3
0
        public CachingTypeConverterSource(
            IDictionary <Type, TypeConverter> typeConverterCache,
            ITypeConverterSource typeConverterSource)
        {
            if (typeConverterCache == null)
            {
                throw new ArgumentNullException(nameof(typeConverterCache));
            }

            if (typeConverterSource == null)
            {
                throw new ArgumentNullException(nameof(typeConverterSource));
            }

            this.typeConverterCache  = typeConverterCache;
            this.typeConverterSource = typeConverterSource;
        }
Exemple #4
0
 public CachingTypeConverterSource(ITypeConverterSource typeConverterSource)
     : this(new Dictionary <Type, TypeConverter>(), typeConverterSource)
 {
 }