Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

automapper dependency injection

services.AddAutoMapper(typeof(ProfileTypeFromAssembly1), typeof(ProfileTypeFromAssembly2) /*, ...*/);
Comment

automapper dependency injection

services.AddAutoMapper(profileAssembly1, profileAssembly2 /*, ...*/);
Comment

using automapper without dependency injection

public static class MapperWrapper 
{
    private const 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.";
    private const string AlreadyInitialized = "Mapper already initialized. You must call Initialize once per application domain/process.";

    private static IConfigurationProvider _configuration;
    private static IMapper _instance;

    private static IConfigurationProvider Configuration
    {
        get => _configuration ?? throw new InvalidOperationException(InvalidOperationMessage);
        set => _configuration = (_configuration == null) ? value : throw new InvalidOperationException(AlreadyInitialized);
    }

    public static IMapper Mapper
    {
        get => _instance ?? throw new InvalidOperationException(InvalidOperationMessage);
        private set => _instance = value;
    }

    public static void Initialize(Action<IMapperConfigurationExpression> config)
    {
        Initialize(new MapperConfiguration(config));
    }

    public static void Initialize(MapperConfiguration config)
    {
        Configuration = config;
        Mapper = Configuration.CreateMapper();
    }

    public static void AssertConfigurationIsValid() => Configuration.AssertConfigurationIsValid();
}
Comment

PREVIOUS NEXT
Code Example
Java :: Write program for problem 1 such that every regex runs as its own thread in java 
Java :: codegrepper java instanceof 
Java :: how to declare an array list of a clas 
Java :: java tostring methode überschreiben 
Java :: Android: how to mark my app as debuggable? 
Java :: jagermeister price in bangalore 
Java :: c# param.ExStyle equivalent in java 
Java :: how to convert a jsonobject to a dbobject 
Java :: java writing an object 
Java :: java virtual override 
Java :: how to extract value from payload in java 
Java :: java add forward / at the end of not present 
Java :: select class field from list java 
Java :: disarium number in java 
Java :: vec add to text field java 
Java :: Use following code to open activity while your application is not running. 
Java :: Statement sql= clsConexion.getConexion().createStatement(); 
Java :: Custom Layout to listview 
Java :: room ktx dependency 
Java :: AndroidManifest.xml file describes the fundamental characteristics of the app and defines each of its components 
Java :: Which type of Exception will be thrown by forName() method 
Java :: xml definition file for spring 
Java :: change button background drawable in code 
Java :: sorting boolean array with prime index 
Java :: Goodbye to "Inspect Element" 
Java :: what is minecraft default render distance 
Java :: java.awt.datatransfer.clipboard example 
Java :: java Prefix Sum of Matrix (Or 2D Array) 
Java :: arraylistof objects 
Java :: how to load template file from resource folder in spring boot project 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =