当前位置: 首页>>代码示例>>C#>>正文


C# IMappingEngine.Map方法代码示例

本文整理汇总了C#中IMappingEngine.Map方法的典型用法代码示例。如果您正苦于以下问题:C# IMappingEngine.Map方法的具体用法?C# IMappingEngine.Map怎么用?C# IMappingEngine.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMappingEngine的用法示例。


在下文中一共展示了IMappingEngine.Map方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        public void Initialize()
        {
            _uow = A.Fake<IUnitOfWork>();
            _mapper = A.Fake<IMappingEngine>();
            _service = new PromotionService(_uow, _mapper);

            _nonExistingPromotion = new Promotion();
            _existingPromotion = new Promotion();
            _promotionWithNoPayments = new Promotion();
            _promotionWithPayments = new Promotion();

            _nonExistingPromotionDTO = new PromotionDTO();
            _existingPromotionDTO = new PromotionDTO();
            _promotionWithNoPaymentsDTO = new PromotionDTO();
            _promotionWithPaymentsDTO = new PromotionDTO();

            A.CallTo(() => _mapper.Map<Promotion>(_nonExistingPromotionDTO)).Returns(_nonExistingPromotion);
            A.CallTo(() => _mapper.Map<Promotion>(_existingPromotionDTO)).Returns(_existingPromotion);
            A.CallTo(() => _mapper.Map<Promotion>(_promotionWithNoPaymentsDTO)).Returns(_promotionWithNoPayments);
            A.CallTo(() => _mapper.Map<Promotion>(_promotionWithPaymentsDTO)).Returns(_promotionWithPayments);

            A.CallTo(() => _uow.PromotionRepository.IsExisting(_nonExistingPromotion)).Returns(false);
            A.CallTo(() => _uow.PromotionRepository.IsExisting(_existingPromotion)).Returns(true);
            A.CallTo(() => _uow.PromotionRepository.HasPayments(_promotionWithPayments)).Returns(true);
            A.CallTo(() => _uow.PromotionRepository.HasPayments(_promotionWithNoPayments)).Returns(false);
        }
开发者ID:EmilyWatsonCF,项目名称:ResortManager,代码行数:26,代码来源:PromotionServiceTests.cs

示例2: ExampleModule

        public ExampleModule(IRepositoryOfId<int> repository, IMappingEngine engine, ISendOnlyBus bus)
        {
            Get["/examples"] = _ => repository.Query<ExampleEntity>()
                .Project().To<ExampleModel>()
                .ToList();

            Get["/example/{id:int}"] = _ => {
                var entity = repository.Load<ExampleEntity>(_.id);
                return engine.Map<ExampleEntity, ExampleModel>(entity);
            };

            Post["/examples"] = _ => {
                var model = this.BindAndValidateModel<NewExampleModel>();

                var entity = new ExampleEntity(model.Name);
                repository.Save(entity);

                return new NewExampleCreatedModel { Id = entity.ID };
            };

            Post["/examples/close"] = _ => {
                var model = this.BindAndValidateModel<CloseExampleModel>();
                bus.Send(new CloseExampleCommand {Id = model.Id});
                return HttpStatusCode.OK;
            };

            Delete["/example/{id:int}"] = _ => {
                repository.Delete<ExampleEntity>(_.id);
                return HttpStatusCode.OK;
            };
        }
开发者ID:techvenky,项目名称:microservice-template-compact,代码行数:31,代码来源:ExampleModule.cs

示例3: Initialize

        public void Initialize()
        {
            _uow = A.Fake<IUnitOfWork>();
            _mapper = A.Fake<IMappingEngine>();
            _service = new HouseService(_uow, _mapper);

            // Initializing HouseDTO's
            _nonExistingHouseDTO = new HouseDTO();
            _existingHouseDTO = new HouseDTO();
            _houseWithBookingsDTO = new HouseDTO();
            _houseWithNoBookingsDTO = new HouseDTO();

            // Initializing Houses
            _nonExistingHouse = new House();
            _existingHouse = new House();
            _houseWithBookings = new House();
            _houseWithNoBookings = new House();

            // Controlling mapper behaviour
            A.CallTo(() => _mapper.Map<House>(_nonExistingHouseDTO)).Returns(_nonExistingHouse);
            A.CallTo(() => _mapper.Map<House>(_existingHouseDTO)).Returns(_existingHouse);
            A.CallTo(() => _mapper.Map<House>(_houseWithBookingsDTO)).Returns(_houseWithBookings);
            A.CallTo(() => _mapper.Map<House>(_houseWithNoBookingsDTO)).Returns(_houseWithNoBookings);

            // Controlling service behaviour
            A.CallTo(() => _uow.HouseRepository.IsDuplicate(_nonExistingHouse)).Returns(false);
            A.CallTo(() => _uow.HouseRepository.IsDuplicate(_existingHouse)).Returns(true);
            A.CallTo(() => _uow.HouseRepository.HasBookings(_houseWithBookings)).Returns(true);
            A.CallTo(() => _uow.HouseRepository.HasBookings(_houseWithNoBookings)).Returns(false);
        }
开发者ID:EmilyWatsonCF,项目名称:ResortManager,代码行数:30,代码来源:HouseServiceTests.cs

示例4: UserModule

        public UserModule(IMappingEngine mappingEngine, IReadOnlyRepository readOnlyRepository)
        {
            Get["/me"] = r => mappingEngine.Map<User, MeResponse>(this.UserSession().User);

            Get["/user/exists"] =
                r =>
                    {
                        bool exists = false;
                        bool activated = false;
                        var email = (string) Request.Query.email;
                        try
                        {
                            var user =
                                readOnlyRepository.First<User>(x => x.Email == email);
                            exists = true;
                            activated = user.Activated;
                        }
                        catch (ItemNotFoundException<User>)
                        {
                        }
                        return new UserExistenceResponse
                                   {
                                       Exists = exists,
                                       Activated = activated,
                                   };
                    };
        }
开发者ID:kmiloaguilar,项目名称:FireTower,代码行数:27,代码来源:UserModule.cs

示例5: UserModule

        public UserModule(IMappingEngine mappingEngine, IReadOnlyRepository readOnlyRepository)
        {
            Get["/me"] = r =>
                             {
                                 return mappingEngine.Map<User, MeResponse>(this.UserSession().User);
                             };

            Get["/user/exists"] =
                r =>
                {
                    bool exists = false;
                    bool activated = false;
                    var facebookid = (long)Request.Query.facebookid;
                    try
                    {
                        var user =
                            readOnlyRepository.First<User>(x => x.FacebookId == facebookid);
                        if (user != null)
                        {
                            exists = true;
                            activated = user.Verified;
                        }

                    }
                    catch (ItemNotFoundException<User>)
                    {
                    }
                    return new UserExistenceResponse
                    {
                        Exists = exists,
                        Activated = activated,
                    };
                };
        }
开发者ID:rsiwady29,项目名称:FireTower,代码行数:34,代码来源:UserModule.cs

示例6: AdminModule

        public AdminModule(IReadOnlyRepository readOnlyRepository, IMappingEngine mappingEngine,
            ICommandDispatcher commandDispatcher)
        {
            Get["/users"] =
                _ =>
                    {
                        this.RequiresClaims(new[] { "Administrator" });
                        var request = this.Bind<AdminUsersRequest>();
                      
                        var parameter = Expression.Parameter(typeof(User), "User");
                        var mySortExpression = Expression.Lambda<Func<User, object>>(Expression.Property(parameter, request.Field), parameter);
                        
                        IQueryable<User> users =
                            readOnlyRepository.Query<User>(x => x.Name != this.UserLoginSession().User.Name).AsQueryable();

                        var orderedUsers = users.OrderBy(mySortExpression);

                        IQueryable<User> pagedUsers = orderedUsers.Skip(request.PageSize * (request.PageNumber - 1)).Take(request.PageSize);

                        List<AdminUserResponse> mappedItems = mappingEngine
                            .Map<IQueryable<User>, IEnumerable<AdminUserResponse>>(pagedUsers).ToList();

                        return new AdminUsersListResponse(mappedItems);
                    };

            Post["/users/enable"] =
                _ =>
                {
                   this.RequiresClaims(new[] {"Administrator"});
                    var request = this.Bind<AdminEnableUsersRequest>();
                    if (request.Enable)
                    {
                        commandDispatcher.Dispatch(this.UserSession(), new EnableUser(request.Id)); 
                    }
                    else
                    {
                        commandDispatcher.Dispatch(this.UserSession(), new DisableUser(request.Id));
                    }
                
                    return null;
                };

            Get["/user/{userId}"] =
                _ =>
                {
                    var userId = Guid.Parse((string)_.userId);
                    var user = readOnlyRepository.GetById<User>(userId);
                    var mappedUser = mappingEngine
                            .Map<User, AdminUserResponse>(user);
                    return mappedUser;
                };

            Post["/user"] =
                _ =>
                {
                    var request = this.Bind<AdminUpdateUserRequest>();
                    commandDispatcher.Dispatch(this.UserSession(), new UpdateUserProfile(request.Id, request.Name, request.Email));
                    return null;
                };

            

        }
开发者ID:ZSnake,项目名称:backend-class,代码行数:63,代码来源:AdminModule.cs

示例7: WhenGetGenreFromRepo_ShouldCallMapper

            public void WhenGetGenreFromRepo_ShouldCallMapper()
            {
                var genres = _fixture.CreateMany<Genre>().ToList();
                _genreRepository = A.Fake<IEntityRepository<Genre>>();
                A.CallTo(() => _genreRepository.GetAll()).Returns(genres.AsQueryable());

                _mapper = A.Fake<IMappingEngine>();
                A.CallTo(() => _mapper.Map<Genre, GenreDto>(A<Genre>.Ignored)).Returns(A<GenreDto>.Ignored);

                var sut = new GenreServiceBuilder()
                    .WithFakeGenreRepository(_genreRepository)
                    .WithDefaultFakeValidator()
                    .WithFakeMapper(_mapper)
                    .Build();

                IEnumerable<GenreDto> genreDtos = sut.GetGenreDtos();

                foreach (var genre in genres)
                {
                    A.CallTo(() => _mapper.Map<Genre, GenreDto>(genre)).MustHaveHappened(Repeated.Exactly.Once);
                }
            }
开发者ID:sunilmunikar,项目名称:BestPractices,代码行数:22,代码来源:GenreServiceTests.cs

示例8: StoryModule

        public StoryModule(IMappingEngine mappingEngine, IDispatcherFactory dispatcherFactory,
            IReadOnlyRepository readOnlyRepository)
        {
            Delete["{projectId}/stories/{storyId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid storyId = Guid.Parse((string) p.storyId);
                    var command = new DeleteStory(storyId, projectId);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Post["{projectId}/stories/{id}/run"] =
                p =>
                {
                    Guid id = Guid.Parse((string) p.id);
                    Guid projectId = Guid.Parse((string) p.projectId);

                    var command = new QueueStory(projectId, id);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Get["{projectId}/stories/{id}"] =
                p =>
                {
                    Guid storyId = Guid.Parse((string) p.id);
                    var story = readOnlyRepository.GetById<Story>(storyId);
                    StoryDetailResponse storyDetailResponse = mappingEngine.Map<Story, StoryDetailResponse>(story);
                    return storyDetailResponse;
                };

            Get["/projects/{projectId}/stories"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var project = readOnlyRepository.GetById<Project>(projectId);
                    IEnumerable<StoryListingResponse> storyListingResponses =
                        mappingEngine.Map<IEnumerable<Story>, IEnumerable<StoryListingResponse>>(project.Stories);
                    return new StoryListResponse(storyListingResponses.ToList());
                };


            Post["/projects/{projectId}/stories"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var projectData = this.Bind<NewStoryRequest>();
                    var command = new CreateNewStory(projectId, Guid.NewGuid(), projectData.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Put["/projects/{projectId}/stories/{storyId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid storyId = Guid.Parse((string) p.storyId);
                    var projectData = this.Bind<ChangeNameRequest>();
                    var command = new ChangeStoryName(projectId, storyId, projectData.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(),
                            command);
                    return null;
                };
        }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:70,代码来源:StoryModule.cs

示例9: StepModule

        public StepModule(IDispatcherFactory dispatcherFactory, IMappingEngine mappingEngine,
            IProjectRepository projectRepository)
        {
            Post["/scenarios/{scenarioId}/criteria/{criterionId}/steps/{stepId}/started"] =
                p =>
                {
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    Guid criterionId = Guid.Parse((string) p.criterionId);
                    Guid stepId = Guid.Parse((string) p.stepId);

                    var request = this.Bind<TestStartRequest>();

                    var command = new StartStep(scenarioId, criterionId, stepId, request.Time);
                    dispatcherFactory.Create(this.UserSession(), command)
                        .Dispatch(this.UserSession(),
                            command);
                    return null;
                };

            Post["/scenarios/{scenarioId}/criteria/{criterionId}/steps/{stepId}/stopped"] =
                p =>
                {
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    Guid criterionId = Guid.Parse((string) p.criterionId);
                    Guid stepId = Guid.Parse((string) p.stepId);

                    var testResultData = this.Bind<TestResultData>();

                    var command = new StopStep(scenarioId, criterionId, stepId, testResultData.Passing,
                        testResultData.Duration, testResultData.Time, testResultData.Message,
                        testResultData.Screenshot);
                    dispatcherFactory.Create(this.UserSession(), command)
                        .Dispatch(this.UserSession(),
                            command);

                    return null;
                };

            Delete["{projectId}/steps/{id}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var command = new DeleteStep(projectId, Guid.Parse((string) p.id));
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(),
                            command);
                    return null;
                };

            Get["{projectId}/scenarios/{scenarioId}/steps/{stepId}"] =
                p =>
                {
                    Guid stepId = Guid.Parse((string) p.stepId);
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Project project = projectRepository.GetById(projectId);
                    Scenario scenario = project.Stories.SelectMany(x => x.Scenarios)
                        .First(x => x.Id == scenarioId);

                    Step step = scenario
                        .GetLinkedCriteria()
                        .SelectMany(x => x.Criterion.GetSteps())
                        .FirstOrDefault(x => x.Id == stepId);

                    if (step == null) throw new ItemNotFoundException<Step>(stepId);

                    StepDetailResponse stepDetailResponse = mappingEngine.Map<Step, StepDetailResponse>(step);

                    List<LinkedStep> stepRunResults =
                        scenario.GetLinkedCriteria().SelectMany(x => x.GetLinkedSteps()).Where(x => x.Step.Id == stepId)
                            .ToList();

                    stepDetailResponse.Results = stepRunResults.Select(x => new StepResultResponse
                                                                            {
                                                                                Details = x.LastResult().GetDetails(),
                                                                                Duration = x.LastResult().Duration,
                                                                                Message = x.LastResult().GetMessage(),
                                                                                ScreenShotUrl =
                                                                                    x.LastResult().ScreenShotUrl,
                                                                                Time =
                                                                                    x.LastResult().Time.HasValue
                                                                                        ? x.LastResult().Time.Value
                                                                                        : DateTime.MinValue
                                                                            }).ToList();

                    LinkedCriterion linkedCriterion =
                        scenario.GetLinkedCriteria().First(x => x.Criterion.GetSteps().Any(s => s.Id == stepId));
                    LinkedStep linkedStep = linkedCriterion.GetLinkedSteps().First(x => x.Step.Id == stepId);
                    stepDetailResponse.LastRun = linkedStep.LastRun();
                    stepDetailResponse.ScreenShotUrl = linkedStep.GetLastScreenshot();
                    stepDetailResponse.Result = linkedStep.GetTestStatus().ToString();

                    return stepDetailResponse;
                };

            Put["{projectId}/criteria/{criteriaId}/steps/order"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid criteriaId = Guid.Parse((string) p.criteriaId);
//.........这里部分代码省略.........
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:101,代码来源:StepModule.cs

示例10: UserAccountModule

        public UserAccountModule(IReadOnlyRepository readOnlyRepository,ICommandDispatcher commandDispatcher, IPasswordEncryptor passwordEncryptor, IMappingEngine mappingEngine)
        {
            Post["/register"] =
                _ =>
                    {
                        var req = this.Bind<NewUserRequest>();
                        var abilities = mappingEngine.Map<IEnumerable<UserAbilityRequest>, IEnumerable<UserAbility>>(req.Abilities);
                        commandDispatcher.Dispatch(this.UserSession(),
                                                   new CreateEmailLoginUser(req.Email, passwordEncryptor.Encrypt(req.Password), req.Name, req.PhoneNumber, abilities));
                        return null;
                    };


            Post["/register/facebook"] =
                _ =>
                    {
                        var req = this.Bind<FacebookRegisterRequest>();
                        commandDispatcher.Dispatch(this.UserSession(), new CreateFacebookLoginUser(req.id,req.email, req.first_name, req.last_name,req.link,req.name,req.url_image));
                        return null;
                    };

            Post["/register/google"] =
                _ =>
                    {
                        var req = this.Bind<GoogleRegisterRequest>();
                        commandDispatcher.Dispatch(this.UserSession(), new CreateGoogleLoginUser(req.id,req.email,req.name.givenName,req.name.familyName,req.url,req.displayName,req.image.url));
                        return null;
                    };

            Post["/password/requestReset"] =
                _ =>
                {
                    var req = this.Bind<ResetPasswordRequest>();
                    commandDispatcher.Dispatch(this.UserSession(),
                                               new CreatePasswordResetToken(req.Email) );
                    return null;
                };

            Put["/password/reset/{token}"] =
                p =>
                {
                    var newPasswordRequest = this.Bind<NewPasswordRequest>();
                    var token = Guid.Parse((string)p.token);
                    commandDispatcher.Dispatch(this.UserSession(),
                                               new ResetPassword(token, passwordEncryptor.Encrypt(newPasswordRequest.Password)));
                    return null;
                };

            Post["/user/abilites"] = p =>
            {

                var requestAbilites = this.Bind<UserAbilitiesRequest>();
                commandDispatcher.Dispatch(this.UserSession(), new AddAbilitiesToUser(requestAbilites.UserId, requestAbilites.Abilities.Select(x => x.Id)));

                return null;


            };

            Get["/abilities"] = _ =>
            {
                var abilites = readOnlyRepository.GetAll<UserAbility>();

                var mappedAbilites = mappingEngine.Map<IEnumerable<UserAbility>, IEnumerable<UserAbilityRequest>>(abilites);

                return mappedAbilites;
            };
        }
开发者ID:ZSnake,项目名称:backend-class,代码行数:68,代码来源:UserAccountModule.cs

示例11: ProjectModule

        public ProjectModule(IDispatcherFactory dispatcherFactory,
            IProjectRepository projectRepository, IMappingEngine mappingEngine)
        {
            Post["/projects/{id}/run"] =
                p =>
                {
                    Guid id = Guid.Parse((string) p.id);
                    var command = new QueueProject(id);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Get["/projects"] =
                _ =>
                {
                    User user = this.UserLoginSession().User;
                    IEnumerable<Project> projects = projectRepository.GetForUser(user);
                    IEnumerable<ProjectListingResponse> projectListingResponses =
                        mappingEngine.Map<IEnumerable<Project>, IEnumerable<ProjectListingResponse>>(projects);
                    return new ProjectListResponse(projectListingResponses);
                };

            Get["/projects/{projectId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid userId = this.UserLoginSession().User.Id;
                    Project project = projectRepository.GetById(projectId);
                    ProjectDetailsResponse response = mappingEngine.Map<Project, ProjectDetailsResponse>(project);
                    if (response == null) throw new ItemNotFoundException<Project>(projectId);
                    return response;
                };

            Get["/projects/{id}/backup"] =
                p =>
                {
                    throw new NotImplementedException();
                    //Guid id = Guid.Parse((string) p.id);
                    //Project project = projectRepository.GetById(id);

                    //if (project.Collaborators.All(x => x.UserId != this.UserLoginSession().User.Id))
                    //{
                    //    throw new UnauthorizedAccessException("That's not your project!");
                    //}

                    //if (project == null) throw new ItemNotFoundException<Project>(id);

                    //var projectBackupResponse = new ProjectBackupResponse
                    //                            {
                    //                                Name = project.Name,
                    //                                Id = project.Id,
                    //                                History = GetFilteredEventd(project)
                    //                            };
                    //return projectBackupResponse;
                };

            Post["/projects/restore"] =
                p =>
                {
                    throw new NotImplementedException();
                    //string body = Request.Body.AsString();
                    //var projectBackupResponse = JsonConvert.DeserializeObject<ProjectBackupResponse>(body,
                    //    new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.Objects});

                    //var command = new RestoreProject(projectBackupResponse.History);
                    //dispatcherFactory.Create(this.UserLoginSession(), command)
                    //    .Dispatch(this.UserLoginSession(), command);
                    //return null;
                };

            Post["/projects"] =
                _ =>
                {
                    var projectData = this.Bind<NewProjectRequest>();
                    var command = new CreateNewProject(Guid.NewGuid(), projectData.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Put["/projects/{projectId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var projectData = this.Bind<ChangeNameRequest>();
                    var command = new ChangeProjectName(projectId, projectData.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Delete["/projects/{id}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.id);
                    var command = new DeleteProject(projectId);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
//.........这里部分代码省略.........
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:101,代码来源:ProjectModule.cs

示例12: ScenarioModule

        public ScenarioModule(IMappingEngine mappingEngine, IDispatcherFactory dispatcherFactory,
            IReadOnlyRepository readOnlyRepository)
        {
            Post["/scenarios/{scenarioId}/failed"] =
                p =>
                {
                    Guid scenarioId = Guid.Parse((string)p.scenarioId);
                    var input = this.Bind<ScenarioFailureInput>();
                    var command = new FailScenario(scenarioId, input.Message, input.Time);
                    dispatcherFactory.Create(this.UserSession(), command)
                        .Dispatch(this.UserSession(), command);
                    return null;
                };

            Delete["{projectId}/scenarios/{id}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var command = new DeleteScenario(projectId, Guid.Parse((string) p.id));
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Get["{projectId}/scenarios/{id}"] =
                p =>
                {
                    Guid scenarioId = Guid.Parse((string) p.id);
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var scenario = readOnlyRepository.GetById<Scenario>(scenarioId);
                    ScenarioDetailResponse response = mappingEngine.Map<Scenario, ScenarioDetailResponse>(scenario);
                    return response;
                };

            Get["{projectId}/stories/{storyId}/scenarios"] =
                p =>
                {
                    Guid storyId = Guid.Parse((string) p.storyId);
                    var story = readOnlyRepository.GetById<Story>(storyId);
                    IEnumerable<ScenarioListingResponse> scenarioListResponses =
                        mappingEngine.Map<IEnumerable<Scenario>, IEnumerable<ScenarioListingResponse>>(story.Scenarios);
                    return new ScenarioListResponse(scenarioListResponses.ToList());
                };

            Post["{projectId}/scenarios/{id}/run"] =
                p =>
                {
                    Guid id = Guid.Parse((string) p.id);
                    Guid projectId = Guid.Parse((string) p.projectId);

                    var command = new QueueScenario(projectId, id);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Post["{projectId}/stories/{storyId}/scenarios"] =
                p =>
                {
                    Guid storyId = Guid.Parse((string) p.storyId);
                    Guid projectId = Guid.Parse((string) p.projectId);
                    var data = this.Bind<NewScenarioRequest>();
                    var command = new CreateNewScenario(projectId, storyId, Guid.NewGuid(), data.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Put["/projects/{projectId}/scenarios/{scenarioId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    var projectData = this.Bind<ChangeNameRequest>();
                    var command = new ChangeScenarioName(projectId, scenarioId, projectData.Name);
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };
        }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:80,代码来源:ScenarioModule.cs

示例13: ProcessType

 private static IType ProcessType(XmlSchemaElement elem, IMappingEngine mappingEngine)
 {
     return mappingEngine.Map<IClass>(elem);
 }
开发者ID:bverburg,项目名称:Schema2Code,代码行数:4,代码来源:Class1.cs

示例14: CriteriaModule

        public CriteriaModule(IMappingEngine mappingEngine, IDispatcherFactory dispatcherFactory,
            IReadOnlyRepository readOnlyRepository,
            IProjectRepository projectRepository)
        {
            Put["{projectId}/scenarios/{scenarioId}/criteria/order"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    var orderChangeRequests = this.Bind<List<CriterionPriorityChangeRequest>>();
                    var command = new ChangeCriterionOrder(projectId, scenarioId,
                        orderChangeRequests.Select(x => new CriterionOrderChange(x.CriterionId, x.Priority)));
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Delete["{projectId}/scenario/{scenarioId}/criteria/{id}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    var command = new RemoveCriterionFromScenario(projectId, scenarioId, Guid.Parse((string) p.id));
                    dispatcherFactory.Create(this.UserLoginSession(), command)
                        .Dispatch(this.UserLoginSession(), command);
                    return null;
                };

            Get["{projectId}/scenarios/{scenarioId}/criteria"] =
                p =>
                {
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    var scenario = readOnlyRepository.GetById<Scenario>(scenarioId);
                    IEnumerable<CriteriaListingResponse> criteriaListingResponses = mappingEngine
                        .Map<IEnumerable<LinkedCriterion>, IEnumerable<CriteriaListingResponse>>(
                            scenario.GetLinkedCriteria());
                    return new CriteriaListResponse(criteriaListingResponses.ToList());
                };

            Get["{projectId}/scenarios/{scenarioId}/criteria/{criterionId}"] =
                p =>
                {
                    Guid criterionId = Guid.Parse((string) p.criterionId);
                    Guid scenarioId = Guid.Parse((string) p.scenarioId);
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Project project = projectRepository.GetById(projectId);
                    LinkedCriterion linkedCriterion = project.Stories
                        .SelectMany(x => x.Scenarios)
                        .First(x => x.Id == scenarioId).GetLinkedCriteria()
                        .FirstOrDefault(x => x.Criterion.Id == criterionId);

                    if (linkedCriterion == null) throw new ItemNotFoundException<Criterion>(criterionId);

                    CriterionDetailsResponse criterionDetailsResponse =
                        mappingEngine.Map<LinkedCriterion, CriterionDetailsResponse>(linkedCriterion);

                    criterionDetailsResponse.Steps =
                        linkedCriterion.Criterion.GetSteps()
                            .Select(step =>
                                    {
                                        LinkedStep linkedStep =
                                            linkedCriterion.GetLinkedSteps().First(x => x.Step.Id == step.Id);
                                        return new StepListingResponse
                                               {
                                                   StepId = step.Id,
                                                   CriterionId = step.Criterion.Id,
                                                   Priority = step.Priority,
                                                   RunsIn = step.Criterion.RunsIn.ToString(),
                                                   ScreenShotUrl = linkedStep.GetLastScreenshot(),
                                                   Description = step.GetDescription(),
                                                   LastRun = linkedStep.LastRun(),
                                                   Result = linkedStep.GetTestStatus().ToString()
                                               };
                                    }).ToList();

                    return criterionDetailsResponse;
                };

            Get["{projectId}/criteria"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Project project = projectRepository.GetById(projectId);
                    IEnumerable<LinkedCriterion> criteria =
                        project.Stories.SelectMany(x => x.Scenarios).SelectMany(x => x.GetLinkedCriteria())
                            .Distinct(new LinkedCriterionComparer());

                    return
                        new CriteriaListResponse(
                            mappingEngine.Map<IEnumerable<LinkedCriterion>, IEnumerable<CriteriaListingResponse>>(
                                criteria));
                };

            Put["/projects/{projectId}/criteria/{criterionId}"] =
                p =>
                {
                    Guid projectId = Guid.Parse((string) p.projectId);
                    Guid criterionId = Guid.Parse((string) p.criterionId);
                    var projectData = this.Bind<ChangeNameRequest>();
                    var command = new ChangeCriterionName(projectId, criterionId, projectData.Name);
//.........这里部分代码省略.........
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:101,代码来源:CriteriaModule.cs


注:本文中的IMappingEngine.Map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。