示例#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;
            }
        }
示例#2
0
        public SourcedTypeConverter(ITypeConverterSource typeConverterSource)
        {
            if (typeConverterSource == null)
            {
                throw new ArgumentNullException(nameof(typeConverterSource));
            }

            this.typeConverterSource = typeConverterSource;
        }
示例#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;
        }
示例#4
0
 public CachingTypeConverterSource(ITypeConverterSource typeConverterSource)
     : this(new Dictionary <Type, TypeConverter>(), typeConverterSource)
 {
 }