protected AdapterInterceptor(TTarget target, IAdapterMapper adapterMapper, ILoggerFactory?loggerFactory = null) : this(loggerFactory) { Target = target ?? throw new ArgumentNullException(nameof(target)); TargetType = typeof(TTarget); AdapterMapper = adapterMapper ?? throw new ArgumentNullException(nameof(adapterMapper)); }
/// <summary> /// Creates the instance of IAdapterMapper frim qualified name. /// </summary> /// <param name="mapperQualifiedName"></param> /// <returns></returns> public static IAdapterMapper GetAdapterMapper(string mapperQualifiedName) { var mpType = Type.GetType(mapperQualifiedName); if (mpType == null) { throw new Exception(String.Format("Cannot create the type '{0}'.", mapperQualifiedName)); } IAdapterMapper mapper = Activator.CreateInstance(mpType) as IAdapterMapper; if (mapper == null) { throw new Exception(String.Format("Cannot create the instance of mapper '{0}'.", mpType)); } return(mapper); }
public CustomAdapterInterceptor(TTarget target, IAdapterMapper adapterMapper, ILoggerFactory?loggerFactory = null) : base(target, adapterMapper, loggerFactory) { _logger = (loggerFactory?.CreateLogger <CustomAdapterInterceptor <TTarget, TSource1, TDestination1> >()) ?? (ILogger)NullLogger.Instance; }
/// <summary> /// Initializes a new AdapterInterceptor instance. /// </summary> /// <param name="target">Adaptee instance.</param> /// <param name="adapterMapper">Adapter mapper instance.</param> /// <param name="supportedTypePairs">Read-only collection of source/target type pairs which will be mapped. Must also contain reverse mappings for method invocation result mapping.</param> /// <param name="adapterToTargetMethodDictionary">Thread-safe collection of adapter/target method mappings. Used for caching. Will be populated at runtime if empty.</param> /// <param name="loggerFactory">Logger factory instace.</param> public AdapterInterceptor(TTarget target, IAdapterMapper adapterMapper, IReadOnlyDictionary <Type, Type> supportedTypePairs, ConcurrentDictionary <MethodInfo, AdapterInvocationInformation> adapterToTargetMethodDictionary, ILoggerFactory?loggerFactory = null) : this(target, adapterMapper, loggerFactory) { SupportedTypePairs = supportedTypePairs ?? throw new ArgumentNullException(nameof(supportedTypePairs)); AdapterToTargetMethodDictionary = adapterToTargetMethodDictionary ?? throw new ArgumentNullException(nameof(adapterToTargetMethodDictionary)); }