Si hallas alguna incompatibilidad con tu código o trabajo, recuerda probar siempre en un ambiente de testing antes añadir el código al trabajo final.
Ejemplo: usar automapper sin inyección de dependencia
publicstaticclassMapperWrapperprivateconst string InvalidOperationMessage="Mapper not initialized. Call Initialize with appropriate configuration. If you are trying to use mapper instances through a container or otherwise, make sure you do not have any calls to the static Mapper.Map methods, and if you're using ProjectTo or UseAsDataSource extension methods, make sure you pass in the appropriate IConfigurationProvider instance.";privateconst string AlreadyInitialized="Mapper already initialized. You must call Initialize once per application domain/process.";privatestaticIConfigurationProvider _configuration;privatestaticIMapper _instance;privatestaticIConfigurationProviderConfiguration
get => _configuration ??thrownewInvalidOperationException(InvalidOperationMessage);
set => _configuration =(_configuration ==null)? value :thrownewInvalidOperationException(AlreadyInitialized);publicstaticIMapperMapper
get => _instance ??thrownewInvalidOperationException(InvalidOperationMessage);private set => _instance = value;publicstaticvoidInitialize(Action<IMapperConfigurationExpression> config)Initialize(newMapperConfiguration(config));publicstaticvoidInitialize(MapperConfiguration config)Configuration= config;Mapper=Configuration.CreateMapper();publicstaticvoidAssertConfigurationIsValid()=>Configuration.AssertConfigurationIsValid();
Si posees alguna duda y capacidad de prosperar nuestro crónica puedes escribir un informe y con mucho placer lo ojearemos.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)