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


C# RepositoryFactory类代码示例

本文整理汇总了C#中RepositoryFactory的典型用法代码示例。如果您正苦于以下问题:C# RepositoryFactory类的具体用法?C# RepositoryFactory怎么用?C# RepositoryFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Should_Get_Mappings_Specific_To_The_Type_Requested_When_Multiple_Types_Are_Requested

        public void Should_Get_Mappings_Specific_To_The_Type_Requested_When_Multiple_Types_Are_Requested()
        {
            //Arrange
            Func<Type, IMappingConfiguration> mappingsDelegate = x =>
            {
                if (x == typeof(Foo)) return fooMapping;
                if (x == typeof(Bar)) return barMapping;
                if (x == typeof(Baz)) return bazMapping;
                if (x == typeof(Qux)) return quxMapping;
                return null;
            };
            var target = new RepositoryFactory(Settings.Default.Connection, mappingsDelegate);

            //Act
            var repository = target.Create<Foo,Bar,Baz,Qux>();
            try
            {
                repository.Context.AsQueryable<Foo>().ToList();
            }
            catch (Exception)
            {
                //Suppress the error from the context. This allows us to test the mappings peice without having to actually map.
            }

            //Assert
            fooMapping.VerifyAllExpectations();
            barMapping.VerifyAllExpectations();
            bazMapping.VerifyAllExpectations();
            quxMapping.VerifyAllExpectations();
        }
开发者ID:calebjenkins,项目名称:Highway.Data,代码行数:30,代码来源:Given_A_Generic_Repository_Factory.cs

示例2: GepirProductInformationDomainService

 public GepirProductInformationDomainService(IMapper<Product, itemDataLineType> gepirProductMapper, IMapper<Company, partyDataLineType> gepirCompanyMapper, RepositoryFactory repositoryFactory, IRepository<Company> companyRepository)
 {
     _repositoryFactory = repositoryFactory;
     _companyRepository = companyRepository;
     _gepirCompanyMapper = gepirCompanyMapper;
     _gepirProductMapper = gepirProductMapper;
 }
开发者ID:consumentor,项目名称:Server,代码行数:7,代码来源:GepirProductInformationDomainService.cs

示例3: GetBySeasonAndCompetition

        public LeagueTable GetBySeasonAndCompetition(string seasonId, string competitionId)
        {
            SeasonCompetition seasonCompetition;
             using (var seasonCompetitionRepository = new RepositoryFactory().CreateSeasonCompetitionRepository())
             {
            seasonCompetition = seasonCompetitionRepository.Find(sc => sc.SeasonId == seasonId && sc.CompetitionId == competitionId).FirstOrDefault();
            if (seasonCompetition == null)
            {
               string message = $"Combination of season '{seasonId}' and competition '{competitionId}' does not exist";
               throw new NotFoundException(message);
            }
             }

             using (var leagueTableRepository = new RepositoryFactory().CreateLeagueTableRepository())
             {
            var leagueTable = leagueTableRepository.GetBySeasonCompetition(seasonCompetition.Id);
            if (leagueTable == null)
            {
               string message = $"No league table exists for season '{seasonId}' and competition '{competitionId}'";
               throw new NotFoundException(message);
            }

            return leagueTable;
             }
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:25,代码来源:LeagueTableService.cs

示例4: GetCurrentSeason

 public Season GetCurrentSeason()
 {
     using (var seasonRepository = new RepositoryFactory().CreateSeasonRepository())
      {
     return seasonRepository.GetCurrentSeason(Game.Id);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:SeasonService.cs

示例5: IsValid

        public override bool IsValid(object value)
        {
            var keyPhrase = value as string;

            using (var rf = new RepositoryFactory())
                return rf.SEOKeyword.Find(sq => sq.Phrase == keyPhrase && sq.IntStatus != (int)SEOKeywordStatus.New) == null;
        }
开发者ID:bwrobel,项目名称:Experts,代码行数:7,代码来源:IsKeywordUniqueAttribute.cs

示例6: OnAddNewStop

        private void OnAddNewStop(object sender, EventArgs e)
        {
            using (AddNewProductionStopForm form = new AddNewProductionStopForm())
            {
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    ProductionStop newStop = new ProductionStop(form.ProductionStopName);
                    using (RepositoryFactory factory = new RepositoryFactory())
                    {
                        using (IEntityRepository<ProductionStop> repository = factory.CreateEntityRepository<ProductionStop>())
                        {
                            repository.Save(newStop);
                        }

                        using (var repository = factory.CreateEntityRepository<MachineConfiguration>())
                        {
                            foreach (var machine in repository.LoadAll())
                            {
                                List<ProductionStop> stops = new List<ProductionStop>(machine.AvailableProductionStops);
                                stops.Add(newStop);
                                machine.AvailableProductionStops = stops;

                                repository.Save(machine);
                            }
                        }

                        Load();
                    }
                }
            }
        }
开发者ID:mikkela,项目名称:oee,代码行数:31,代码来源:MachineConfigurationUserControl.cs

示例7: Create

        public IEnumerable<Team> Create(Game game, int howMany)
        {
            var teams = new List<Team>();

             using (var formationRepository = new RepositoryFactory().CreateFormationRepository())
             {
            var formations = formationRepository.GetAll();
            bool teamGenerationReady = false;
            while (!teamGenerationReady)
            {
               var team = _teamGenerator.Generate();

               // Team names must be unique.
               bool teamExists = teams.Any(t => t.Name == team.Name);
               if (!teamExists)
               {
                  team.Game = game;
                  team.Formation = _listRandomizer.GetItem(formations);
                  teams.Add(team);
               }

               teamGenerationReady = (teams.Count == howMany);
            }
             }

             return teams;
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:27,代码来源:TeamService.cs

示例8: GetUser

 public User GetUser(string username, string password)
 {
     using (var userRepository = new RepositoryFactory().CreateUserRepository())
      {
     return userRepository.GetByUsernameAndPassword(username, password);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:UserService.cs

示例9: GetNextMatchDay

 public DateTime GetNextMatchDay(string seasonId)
 {
     using (var matchRepository = new RepositoryFactory().CreateMatchRepository())
      {
     return matchRepository.GetNextMatchDay(seasonId);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:MatchService.cs

示例10: GenerateReport

        private void GenerateReport()
        {
            System.Windows.Forms.Cursor cursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                using (RepositoryFactory factory = new RepositoryFactory())
                {

                    using (IProductionQueryRepository repository = factory.CreateProductionQueryRepository())
                    {
                        ProductionQuery query = new ProductionQuery().AddDateRange(dtPeriodStart.Value,
                                                                                   dtPeriodEnd.Value);
                        if (!string.IsNullOrEmpty(txtProduct.Text))
                            query = query.AddProduct(new ProductNumber(txtProduct.Text));
                        if (!string.IsNullOrEmpty(txtOrder.Text))
                            query = query.AddOrder(new OrderNumber(txtOrder.Text));
                        if (cbMachine.SelectedItem != null)
                            query = query.AddMachine(cbMachine.SelectedItem.ToString());
                        if (cbTeam.SelectedItem != null)
                            query = query.AddTeam((ProductionTeam) cbTeam.SelectedItem);

                        ShowResults(query, repository.LoadProductions(query));
                    }
                }
            } finally
            {
                Cursor.Current = cursor;
            }
        }
开发者ID:mikkela,项目名称:oee,代码行数:30,代码来源:GenerateReportForm.cs

示例11: If_Passed_Context_Is_Null_Must_Throw_Exception

 public void If_Passed_Context_Is_Null_Must_Throw_Exception()
 {
     //
     // Arrange, Act, Assert
     //
     var repositoryFactory = new RepositoryFactory(null);
 }
开发者ID:Cheranga,项目名称:DAL,代码行数:7,代码来源:RepositoryFactoryTest.cs

示例12: GetByRound

 public IEnumerable<Match> GetByRound(Round round)
 {
     using (var matchRepository = new RepositoryFactory().CreateMatchRepository())
      {
     return matchRepository.GetByRound(round.Id);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:MatchService.cs

示例13: btnUpdateBaseCost_Click

        private void btnUpdateBaseCost_Click(object sender, EventArgs e)
        {
            using (RepositoryFactory factory = new RepositoryFactory())
            {
                using (
                    IEntityRepository<MachineConfiguration> repository =
                        factory.CreateEntityRepository<MachineConfiguration>())
                {
                    List<MachineConfiguration> machines = new List<MachineConfiguration>(repository.LoadAll());

                    using (BaseCostForm form = new BaseCostForm())
                    {
                        form.Machines = machines;
                        if (form.ShowDialog(this) == DialogResult.OK)
                        {
                            foreach (var machine in machines)
                            {
                                repository.Save(machine);
                            }
                            LoadData(machines);
                        }
                    }
                }

            }
        }
开发者ID:mikkela,项目名称:oee,代码行数:26,代码来源:MainForm.cs

示例14: GetMyTeam

 public Team GetMyTeam(Game game)
 {
     using (var teamRepository = new RepositoryFactory().CreateTeamRepository())
      {
     return teamRepository.GetTeam(game.CurrentTeamId);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:TeamService.cs

示例15: Get

 public Season Get(string seasonId)
 {
     using (var seasonRepository = new RepositoryFactory().CreateSeasonRepository())
      {
     return seasonRepository.GetOne(seasonId);
      }
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:SeasonService.cs


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