示例#1
0
        public ContactService(AutoMapper.IMapper mapper, IDbConnection connection)
        {
            this.connection = connection;

            database    = new Database(connection);
            this.mapper = mapper;
        }
示例#2
0
        public void Init(int randomDataSampleSize, int listMapperListSize = 1000)
        {
            RandomDataSampleSize = randomDataSampleSize;

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <B, B>();
                cfg.CreateMap <C, C>();
                cfg.CreateMap <D, D>();
                cfg.CreateMap <E, E>();
                cfg.CreateMap <F, F>();
                cfg.CreateMap <B, BDto>();
                cfg.CreateMap <C, CDto>();
                cfg.CreateMap <D, DDto>();
                cfg.CreateMap <E, EDto>();
                cfg.CreateMap <F, FDto>();

                cfg.CreateMap <BDto, B>();
                cfg.CreateMap <CDto, C>();
                cfg.CreateMap <DDto, D>();
                cfg.CreateMap <EDto, E>();
                cfg.CreateMap <FDto, F>();
            });

            config.AssertConfigurationIsValid();
            _mapper = config.CreateMapper();

            AssignRandomData(randomDataSampleSize);
        }
示例#3
0
        public QualificationApiControllertest()
        {
            var serviceProvider = services.BuildServiceProvider();

            tenderService                = serviceProvider.GetService <ITenderAppService>();
            qualificationAppService      = serviceProvider.GetService <IQualificationAppService>();
            iDMAppService                = serviceProvider.GetService <IIDMAppService>();
            lookupAppService             = serviceProvider.GetService <ILookUpService>();
            supplierqualificationService = serviceProvider.GetService <ISupplierQualificationDocumentAppService>();
            verificationService          = serviceProvider.GetService <IVerificationService>();

            //Configure mapping just for this test
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PreQualificationBasicDetailsModel, PreQualificationBasicDetailsModel>();
                cfg.CreateMap <MOF.Etimad.Monafasat.Core.Entities.Tender, PreQualificationSavingModel>();
                cfg.ValidateInlineMaps = false;
            });

            mapper = config.CreateMapper();

            _mockRootConfiguration = MockHelper.CreateIOptionSnapshotMock(new MOF.Etimad.Monafasat.SharedKernal.RootConfigurations());
            //verificationService = new Mock<IVerificationService>().Object;
            authorizationService = new Mock <IAuthorizationService>().Object;
            supplierService      = new Mock <ISupplierService>().Object;
            offerAppService      = new Mock <IOfferAppService>().Object;
            supplierQualificationDocumentDomainService = new Mock <ISupplierQualificationDocumentDomainService>().Object;
            memoryCache      = new Mock <IMemoryCache>().Object;
            branchAppService = new Mock <IBranchAppService>().Object;

            _qualificationController = new QualificationController(supplierqualificationService, qualificationAppService, mapper, verificationService,
                                                                   iDMAppService, authorizationService, supplierService, offerAppService, lookupAppService, tenderService, supplierQualificationDocumentDomainService, _mockRootConfiguration);

            _lookupController = new LookupController(lookupAppService, mapper, iDMAppService, branchAppService, memoryCache, _mockRootConfiguration);
        }
示例#4
0
        public UserStreamDalCassandra(string keyspace = "SocialNetwork", string[] nodes = null, ConsistencyLevel consistencyLevel = ConsistencyLevel.One)
        {
            nodes = new string[] { "127.0.0.1" };
            var conf = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new UserStreamProfile());
                mc.AddProfile(new PostStreamProfile());
            });

            _StreamMapper = conf.CreateMapper();
            _keyspace     = keyspace;
            _cluster      = Cluster.Builder()
                            .AddContactPoints(nodes)
                            .WithQueryOptions(new QueryOptions().SetConsistencyLevel(consistencyLevel))
                            .Build();
            if (MappingConfiguration.Global.Get <StreamProfile>() == null)
            {
                MappingConfiguration.Global.Define <StreamProfile>();
            }
            if (MappingConfiguration.Global.Get <UserProfile>() == null)
            {
                MappingConfiguration.Global.Define <UserProfile>();
            }
            if (MappingConfiguration.Global.Get <UserStreamProfile>() == null)
            {
                MappingConfiguration.Global.Define <UserStreamProfile>();
            }
        }
示例#5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(); // Make sure you call this previous to AddMvc
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddDbContext <AddressbookContext>(opt =>
                                                       opt.UseInMemoryDatabase("TodoList"));


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
            services.AddScoped <IAddressbookContext, AddressbookContext>();



            services.AddMvc();

            //Automapper configuration files
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Models.Contact, DBModels.Contact>();
                cfg.CreateMap <DBModels.Contact, Models.Contact>();
            });

            AutoMapper.IMapper mapper = config.CreateMapper();
            services.AddSingleton(mapper);



            //Database configuration files
            string   conString = Configuration.GetValue <string>("Data:ConnectionString");
            Database db        = new Database(conString, "System.Data.SqlClient");

            services.AddSingleton(db);
        }
示例#6
0
        private static void MapEntities()
        {
            var config = MapBOEntities();

            AutoMapper.IMapper mapper = config.CreateMapper();
            AopEngine.Container.RegisterInstance(mapper);
        }
示例#7
0
 public ProductService(IUnitOfWork uunitOfWork, IMapper mapper, IMyMapper myMapper)
 {
     _unitOfWork                = uunitOfWork;
     _mapper                    = mapper;
     _myMapper                  = myMapper;
     _productRepository         = _unitOfWork.GetRepository <Product>();
     _productCategoryRepository = _unitOfWork.GetRepository <ProductCategory>();
 }
示例#8
0
        public Mapper()
        {
            configurations = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <DefaultMapping>();
            });

            mapper = configurations.CreateMapper();
        }
 public PagesController(
     ILogger <PagesController> logger,
     IMapper mapper,
     IDocumentService <SharedContentItemModel> sharedContentItemDocumentService)
 {
     this.logger = logger;
     this.mapper = mapper;
     this.sharedContentItemDocumentService = sharedContentItemDocumentService;
 }
示例#10
0
        public void OneTimeSetup()
        {
            var mapperConfiguration = new MapperConfiguration(cfg =>
                                                              cfg.AddProfiles(new[] { new StudentProfile() }));

            mapperConfiguration.CompileMappings();
            mapperConfiguration.AssertConfigurationIsValid();
            mapper = mapperConfiguration.CreateMapper();
        }
 public static void RegisterAutoMappers()
 {
     Mapping = new MapperConfiguration(config =>
     {
         config.CreateMap <Product, ProductViewModel>();
         config.CreateMap <ProductCategory, ProductCategoryViewModel>();
         config.CreateMap <Tag, TagViewModel>();
         config.CreateMap <ProductTag, ProductTagViewModel>();
     }).CreateMapper();
 }
示例#12
0
 public ExchangeMailService(ProfileRegister register,
                            ExchangeProfileDataStore.Factory storeFactory,
                            MSGraph.GraphServiceClient client,
                            AM.IMapper mapper)
 {
     _register     = register;
     _storeFactory = storeFactory;
     _client       = client;
     _mapper       = mapper;
 }
示例#13
0
 public VooService(AutoMapper.IMapper mapper,
                   IAeroportoRepository aeroportoRepository,
                   IAeronaveRepository aeronaveRepository,
                   IVooRepository repositorio,
                   LNoty notificacoes) : base(repositorio, notificacoes)
 {
     _aeroportoRepository = aeroportoRepository;
     _aeronaveRepository  = aeronaveRepository;
     _mapper = mapper;
 }
示例#14
0
        /// <summary>
        /// Method to map object from source into target
        /// </summary>
        /// <typeparam name="T">source generic type</typeparam>
        /// <typeparam name="K">target object generic type</typeparam>
        /// <param name="source">source object</param>
        /// <param name="target">target object</param>
        public void Map <T, K>(T source, K target)
        {
            var config = new MapperConfiguration(cfg => { cfg.CreateMap <T, K>(); });

            // CreateMap<T, K>();
            AutoMapper.IMapper iMapper = config.CreateMapper();
            //var source = new T();
            var destination = iMapper.Map <T, K>(source);

            iMapper.Map(source, target);
        }
 public FarmerSchedulerRepository(AutoMapper.IMapper mapper, ISchedulerFactory schedulerFactory)
 {
     _schedulerFactory                = schedulerFactory ?? throw new ArgumentNullException(nameof(schedulerFactory));
     _mapper                          = mapper;
     _Database                        = new Database(DatabaseConfigure.DBConnec, DatabaseConfigure.DBProvider, null);
     _verificationAddSchedulerData    = new VerificationAddSchedulerData();
     _verificationSelectSchedulerData = new VerificationSelectSchedulerData();
     _verificationUpdateSchedulerData = new VerificationUpdateSchedulerData();
     _jobDetailAndTrigger             = new JobDetailAndTrigger(schedulerFactory);
     scheduler                        = _schedulerFactory.GetScheduler().Result;
 }
示例#16
0
 public LocationService(
     ILogger <LocationService> logger,
     AutoMapper.IMapper mapper,
     EventManagementDbContext context,
     ILocationRepository repository)
 {
     this.logger     = logger;
     this.mapper     = mapper;
     this.context    = context;
     this.repository = repository;
 }
示例#17
0
        public static void MapperInit(Type src, Type dst)
        {
            mapperConfig = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.CreateMap(src, dst);
                cfg.AllowNullCollections       = true;
                cfg.AllowNullDestinationValues = true;
            });

            iMapper = mapperConfig.CreateMapper();
            iMapper.ConfigurationProvider.CompileMappings();
        }
示例#18
0
        public UserManagementServiceTest()
        {
            var dbContextOptionBuilder = new DbContextOptionsBuilder <UserManagementContext>().UseInMemoryDatabase(databaseName: "temp");
            var userContext            = new UserManagementContext(dbContextOptionBuilder.Options);
            var mappingConfiguration   = new MapperConfiguration(mc => {
                mc.CreateMap <List <User>, List <UserViewModel> >();
                mc.CreateMap <CreateUserViewModel, User>();
            });

            this.mapper = new AutoMapper.Mapper(mappingConfiguration);
            this.userManagementService = new UserManagementService(userContext, this.mapper);
        }
示例#19
0
        private IUnityContainer CreateAndConfigreContainer()
        {
            var mapperConfiguration = new AutoMapper.MapperConfiguration(cfg => cfg.CreateMap <SalesRecord, SalesRecordDTO>());

            _autoMapper = mapperConfiguration.CreateMapper();

            var container = new UnityContainer();

            container.RegisterInstance(_autoMapper);
            container.RegisterType <ApplicationDbContext, ApplicationDbContext>();
            container.RegisterType <ISalesRecordsDataService, SalesRecordsDataService>();
            return(container);
        }
示例#20
0
文件: BookService.cs 项目: neozhu/bms
 public BookService(
     AutoMapper.IMapper mapper,
     IRepositoryAsync <Book> repository,
     IDataTableImportMappingService mappingservice,
     NLog.ILogger logger
     )
     : base(repository)
 {
     this.mapper         = mapper;
     this.repository     = repository;
     this.mappingservice = mappingservice;
     this.logger         = logger;
 }
示例#21
0
        public AutoMapperMapper(IEnumerable <MappingProfile> profiles)
        {
            var configuration = new MapperConfiguration(
                x =>
            {
                foreach (var profile in profiles)
                {
                    x.AddProfile(profile);
                }
            }
                );

            mapper = configuration.CreateMapper();
        }
示例#22
0
        public void Init(int randomDataSampleSize, int listMapperListSize = 1000)
        {
            RandomDataSampleSize = randomDataSampleSize;

            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <DeepBCDEF, DeepCDE>();
                cfg.CreateMap <DeepCDE, DeepBCDEF>();
            });

            config.AssertConfigurationIsValid();
            _mapper = config.CreateMapper();
            AssignRandomDataLists(randomDataSampleSize, listMapperListSize);
        }
示例#23
0
                static async Task <MailFolder> RequestSpecialFolder(MSGraph.IMailFolderRequestBuilder requestBuilder,
                                                                    FolderType type, bool isFavorite,
                                                                    AM.IMapper mapper)
                {
                    var folder = await requestBuilder.Request()
                                 .GetAsync()
                                 .ConfigureAwait(false);

                    return(mapper.Map <MSGraph.MailFolder, MailFolder>(folder, opt => opt.AfterMap((src, dst) =>
                    {
                        dst.IsFavorite = isFavorite;
                        dst.Type = type;
                    })));
                }
示例#24
0
        public static List <TDest> MapList <TSource, TDest>(this AutoMapper.IMapper Mapper, IEnumerable <TSource> Source) where TDest : new()
        {
            var ret = new List <TDest>();

            if (Source != null)
            {
                foreach (var item in Source)
                {
                    var NewItem = Mapper.Map <TSource, TDest>(item);
                    ret.Add(NewItem);
                }
            }
            return(ret);
        }
示例#25
0
        public void GlobalSetup()
        {
            _source = new X[N];
            _dest   = new Y[N];

            MappingConfiguration.Add <ExplicitMapperConfiguration>();
            MappingConfiguration.Build();
            _explicitMapper = new MapperInstance();

            var automapperConfig = new MapperConfiguration(c => c.AddProfile(new AutoMapperProfile()));

            automapperConfig.AssertConfigurationIsValid();
            _autoMapper = automapperConfig.CreateMapper();
        }
示例#26
0
        public CommonMapper()
        {
            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <User, UserProxy>();
                cfg.CreateMap <UserProxy, User>();
                cfg.CreateMap <Post, PostModel>();
                cfg.CreateMap <PostModel, Post>();
                cfg.CreateMap <Character, CharacterModel>();
                cfg.CreateMap <CharacterModel, Character>();
                cfg.CreateMap <CommentModel, Comment>();
                cfg.CreateMap <Comment, CommentModel>();
            });

            mapper = config.CreateMapper();
        }
 public CmsApiService(
     CmsApiClientOptions cmsApiClientOptions,
     IApiDataProcessorService apiDataProcessorService,
     HttpClient httpClient,
     IMapper mapper,
     IApiCacheService apiCacheService,
     IContentTypeMappingService contentTypeMappingService)
 {
     this.cmsApiClientOptions     = cmsApiClientOptions;
     this.apiDataProcessorService = apiDataProcessorService;
     this.httpClient                = httpClient;
     this.mapper                    = mapper;
     this.apiCacheService           = apiCacheService;
     this.contentTypeMappingService = contentTypeMappingService;
 }
示例#28
0
        private void Register(ILifetimeScope serviceProvier)
        {
            var mapperConfiguration = new MapperConfiguration.MapperConfigurationExpression();

            IEnumerable <IEntityMapperConfig> configurators = AssemblyFinder.FindAllInterfaces <IEntityMapperConfig>();

            foreach (IEntityMapperConfig mapperConfigurationInstance in configurators)
            {
                mapperConfigurationInstance.Config(mapperConfiguration, serviceProvier);
            }

            Mapper.Initialize(mapperConfiguration);
            IMapper createdMapper = Mapper.Configuration.CreateMapper();

            _mapper = createdMapper;
        }
示例#29
0
        // IConfiguration iconfiguration;
        public AddressbookContext(DbContextOptions <AddressbookContext> options, IConfiguration iconfig, AutoMapper.IMapper mapper, Database db)
            : base(options)
        {
            //  this.db = new Database("Data Source=INTDEV-PC;Initial Catalog=LearningDb-Sailesh;User ID=Intern;Password=P@ssw0rd", "System.Data.SqlClient");
            string conString = iconfig.GetValue <string>("Data:ConnectionString");

            // this.db = new Database(conString, "System.Data.SqlClient");
            this.db = db;

            //var config = new MapperConfiguration(cfg =>
            //{
            //    cfg.CreateMap<Models.Contact, DBModels.Contact>();
            //    cfg.CreateMap<DBModels.Contact, Models.Contact>();
            //});
            this.mapper = mapper;
        }
示例#30
0
        public ObjMapper(ISqlProcServ sqlProcServ, ICarriageServ carrServ, IReservSeatServ seatServ, IStationOnRouteServ statOnRouteServ, IPersonServ personServ, ITicketServ ticketServ)
        {
            this.seatServ        = seatServ;
            this.sqlProcService  = sqlProcServ;
            this.carrServ        = carrServ;
            this.statOnRouteServ = statOnRouteServ;
            this.personServ      = personServ;
            this.ticketServ      = ticketServ;

            config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <TrainByTwoStationsAndDate, TrainByStationsAndDate>();
                cfg.CreateMap <CarriageTypeInTrain, CarrTypesAndCountOfSeats>();
                cfg.CreateMap <FreeSeatInCarr, FreeSeatInCarriage>();
                cfg.AllowNullCollections = true;
            });
            mapper = config.CreateMapper();
        }