/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="currentAccountProvider"></param>
 /// <param name="mapper"></param>
 public BaseController(
     ICurrentAccountProvider currentAccountProvider,
     Mapper mapper)
 {
     CurrentAccountProvider = currentAccountProvider;
     Mapper = mapper.DefaultContext.Mapper;
 }
        public void TestCaseSetup()
        {
            _group = new Group
            {
                Id          = "00000000-0000-0000-0000-000000000000",
                AdminId     = "2",
                Information = "Some product",
                Name        = "Best",
                GroupBoards = null,
                GroupUsers  = null
            };
            _groupDB = new GroupDB
            {
                Id           = "00000000-0000-0000-0000-000000000000",
                AdminId      = "2",
                Information  = "Some product",
                Name         = "Best",
                Created      = DateTime.UtcNow,
                Deleted      = null,
                IsNotDeleted = true,
                Modified     = DateTime.UtcNow,
                GroupBoards  = null,
                GroupUsers   = null
            };
            _groupDB.GroupBoards = new List <GroupBoardDB>
            {
                new GroupBoardDB
                {
                    Name          = "Name",
                    GroupProducts = new List <GroupProductDB>
                    {
                        new GroupProductDB
                        {
                            Information = "Information"
                        }
                    }
                }
            };
            _groupDB.GroupUsers = new List <GroupUserDB>
            {
                new GroupUserDB
                {
                    RightToCreateBoards = true
                }
            };
            _groupRepositoryMock = new Mock <IGroupRepository>();

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new GroupProfile());
                cfg.AddProfile(new GroupBoardProfile());
                cfg.AddProfile(new GroupProductProfile());
                cfg.AddProfile(new GroupUserProfile());
                cfg.AddProfile(new GroupCommentProfile());
            });

            _mapper       = (new Mapper(config)).DefaultContext.Mapper;
            _groupService = new GroupService(_groupRepositoryMock.Object, _mapper);
            _selectedList = new List <GroupDB>();
        }
Example #3
0
 public ResolutionContext(object source, object destination, TypePair types, MappingOperationOptions options, IRuntimeMapper mapper)
 {
     SourceValue      = source;
     DestinationValue = destination;
     Options          = options;
     Mapper           = mapper;
     Types            = types;
 }
Example #4
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="balanceFacade"></param>
 /// <param name="currentAccountProvider"></param>
 /// <param name="mapper"></param>
 public InProgressPlansViewComponent(BalanceFacade balanceFacade,
                                     ICurrentAccountProvider currentAccountProvider,
                                     Mapper mapper)
 {
     _balanceFacade          = balanceFacade;
     _currentAccountProvider = currentAccountProvider;
     _mapper = mapper.DefaultContext.Mapper;
 }
Example #5
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="currentAccountProvider"></param>
 /// <param name="balanceFacade"></param>
 /// <param name="mapper"></param>
 public GraphViewComponent(ICurrentAccountProvider currentAccountProvider,
                           BalanceFacade balanceFacade,
                           Mapper mapper)
 {
     _currentAccountProvider = currentAccountProvider;
     _balanceFacade          = balanceFacade;
     _mapper = mapper.DefaultContext.Mapper;
 }
Example #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="balanceFacade"></param>
 /// <param name="currentAccountProvider"></param>
 /// <param name="mapper"></param>
 public AchievedBadgesViewComponent(
     BalanceFacade balanceFacade,
     ICurrentAccountProvider currentAccountProvider,
     Mapper mapper)
 {
     _balanceFacade          = balanceFacade;
     _currentAccountProvider = currentAccountProvider;
     _mapper = mapper.DefaultContext.Mapper;
 }
Example #7
0
        public AutoMapper()
        {
            MapperConfiguration config = new MapperConfiguration(cfg =>
            {
                Configure(cfg);
            });

            engine = new Mapper(config);
            mapper = engine.DefaultContext.Mapper;
        }
Example #8
0
        public PayPalServiceTests()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AddressProfile());
                cfg.AddProfile(new DonorProfile());
                cfg.AddProfile(new DonationProfile());
            });

            _mapper = (new Mapper(config)).DefaultContext.Mapper;
        }
Example #9
0
        public static Type GetTargetType(Type sourceType, IRuntimeMapper runtimeMapper)
        {
            if (!lookup.TryGetValue(sourceType.FullName, out var targetType))
            {
                var mapper = runtimeMapper.GetType()
                             .GetField("_inner", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
                             .GetValue(runtimeMapper) as Mapper;

                targetType = mapper.ConfigurationProvider.GetAllTypeMaps().Single(m => m.SourceType == sourceType).DestinationType;

                lookup[sourceType.FullName] = targetType;
            }

            return(targetType);
        }
Example #10
0
        public static void InitializeMapper()
        {
            if (MapperInstance != null)
            {
                throw new MethodAccessException("AutoMapper is already instantiated!");
            }

            AutoMapper.Mapper.Initialize(cfg =>
            {
                // ProductsShop Models Mappings
                cfg.AddProfile <CategoriesByProductsCountDtoProfile>();
                cfg.AddProfile <SuccessfullySoldProductsDtoProfile>();

                // ---------------- SuccessfullySoldProductsDto
                cfg.CreateMap <Product, ProductBuyerDto>()
                .ForMember(dest => dest.BuyerFirstName, opt => opt.MapFrom(src => src.Buyer.FirstName))
                .ForMember(dest => dest.BuyerLastName, opt => opt.MapFrom(src => src.Buyer.LastName));

                // ----------------
                cfg.CreateMap <Product, ProductsInRangeDto>()
                .ForMember(dest => dest.Seller,
                           opt => opt.MapFrom(p => p.Seller.FirstName + " " + p.Seller.LastName));

                // CarRental Models Mappings
                cfg.AddProfile <TotalSalesByCustomerDtoProfile>();
                cfg.AddProfile <SalesWithAppliedDiscountDtoProfile>();
                cfg.AddProfile <CarsWithTheirListOfPartsDtoProfile>();

                cfg.CreateMap <Car, CarsFromMakeDto>();
                cfg.CreateMap <Car, CarDto>();
                cfg.CreateMap <Part, PartDto>();

                cfg.CreateMap <Customer, CustomerDto>()
                .ForMember(dest => dest.Sales, opt => opt.Ignore());

                cfg.CreateMap <Supplier, LocalSuppliersDto>()
                .ForMember(dest => dest.PartsCount,
                           opt => opt.MapFrom(src => src.Parts.Count));
            });


            MapperInstance = AutoMapper.Mapper.Instance as Mapper;

            Mapper = MapperInstance.DefaultContext.Mapper;
        }
        public static void RegisterDependencyResolver(IRuntimeMapper mapper)
        {
            _container = new Container();
            _container.Options.DefaultScopedLifestyle = new WebRequestLifestyle();

            _container.Register <MsdbEntities>(Lifestyle.Scoped);
            _container.Register <IJobDetailService, JobDetailService>();
            _container.Register <IJobRepository, JobRepository>();
            _container.Register <IDateTimeService, DateTimeService>();
            _container.Register <IDataMapper>(() => new DataMapper(mapper));

            mapper.DefaultContext.Options.ConstructServicesUsing(_container.GetInstance);

            _container.RegisterMvcControllers(Assembly.GetExecutingAssembly());

            _container.RegisterMvcIntegratedFilterProvider();

            _container.Verify();

            DependencyResolver.SetResolver(_container);
        }
 public RequestExecutionWrapper(IBrowser browser, IRuntimeMapper mapper)
 {
     Browser = browser;
     Mapper  = mapper;
 }
Example #13
0
 /// <summary>
 /// Ctor for ExpenseManagerCrudServiceBase
 /// </summary>
 /// <param name="repository">repository used by this service</param>
 /// <param name="expenseManagerMapper">mapper</param>
 /// <param name="unitOfWorkProvider">unitOfWork provider</param>
 protected ExpenseManagerCrudServiceBase(ExpenseManagerRepository <TEntity, TKey> repository, Mapper expenseManagerMapper, IUnitOfWorkProvider unitOfWorkProvider)
 {
     UnitOfWorkProvider   = unitOfWorkProvider;
     Repository           = repository;
     ExpenseManagerMapper = expenseManagerMapper.DefaultContext.Mapper;
 }
 public ResolutionContext(object source, object destination, TypePair types, MappingOperationOptions options, IRuntimeMapper mapper)
 {
     SourceValue = source;
     DestinationValue = destination;
     Options = options;
     Mapper = mapper;
     Types = types;
 }
Example #15
0
 public AccountController(IUserService <UserDTO, RoleDTO> service, IRuntimeMapper mapper, IAuthenticationManager authManager)
 {
     _userService = service;
     _mapper      = mapper;
     _authManager = authManager;
 }
Example #16
0
 public MappingTests()
 {
     _mapper = MapperHelper.CreateNewMapperInstance();
 }
Example #17
0
 public UserAdminController(IUserService <UserDTO, RoleDTO> service, IRuntimeMapper mapper)
 {
     _userService = service;
     _mapper      = mapper;
 }
Example #18
0
 /// <summary>
 /// Resolve a service from the mapper's dependency injection resolver.
 /// </summary>
 /// <returns>The resolved service.</returns>
 /// <param name="mapper">The mapper.</param>
 /// <typeparam name="T">The service type.</typeparam>
 public static T Resolve <T>(this IRuntimeMapper mapper)
 {
     return((T)mapper.ServiceCtor(typeof(T)));
 }
Example #19
0
 public ResolutionContext(IMappingOperationOptions options, IRuntimeMapper mapper)
 {
     Options = options;
     Mapper  = mapper;
 }
Example #20
0
 protected ModuleMapper()
 {
     Mapper = new Mapper(new MapperConfiguration(Configure));
 }