public static IServiceCollection AddAnunciosDbAdapter(this IServiceCollection services,
                                                              DbAdapterConfiguration dbAdapterConfiguration)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

            // Registra a instancia do objeto de configuracoes desta camanda.
            services.AddSingleton(dbAdapterConfiguration);

            services.AddScoped <IDbConnection>(d =>
            {
                return(new SqlConnection(dbAdapterConfiguration.SqlConnectionString));
            });

            services.AddScoped <IAnunciosAdapter, AnunciosAdapter>();

            return(services);
        }
Example #2
0
        public DbAdapter(DbAdapterConfiguration configuration, IMapper mapper)
        {
            this.configuration = configuration
                                 ?? throw new ArgumentNullException(nameof(configuration));

            this.mapper = mapper
                          ?? throw new ArgumentException(nameof(mapper));

            usuarios = new List <UsuarioDto>();
        }
Example #3
0
        public static IServiceCollection AddDbAdapter(this IServiceCollection services, DbAdapterConfiguration configuration)
        {
            if (services is null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddScoped <IDbAdapter, DbAdapter>();
            services.AddSingleton(configuration);
            services.AddAutoMapper(typeof(DbAdapterMapperProfile));

            return(services);
        }