• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RepositoryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Initialize

 public void Initialize()
 {
     // No need to mock this repositories as they do not connect to the database but have their data in-memory.
      var repositoryFactory = new RepositoryFactory();
      _positionRepository = repositoryFactory.CreatePositionRepository();
      _formationRepository = repositoryFactory.CreateFormationRepository();
 }
开发者ID:bouwe77,项目名称:fmg,代码行数:7,代码来源:StartingLineupGeneratorTest.cs


示例17: Main

        public static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("nl-NL");
            ConfigurationFactory configurationFactory = new ConfigurationFactory();
            Configuration configuration = configurationFactory.Create();
            if (configuration == null)
            {
                // Newly created.
                return;
            }

            Application.Init();

            if (!authenticate())
            {
                return;
            }

            IDbConnection connection = new ConnectionFactory().createConnection(configuration.ConnectionString);

            IRepositoryFactory repositoryFactory = new RepositoryFactory(connection);

            new MainWindow(repositoryFactory).Show();

            Application.Run();
        }
开发者ID:reinkrul,项目名称:SailorsTabDotNet,代码行数:26,代码来源:Main.cs


示例18: ShouldCreateInstanceOfDesiredRepositoryWithInjectedConntectionString

        public void ShouldCreateInstanceOfDesiredRepositoryWithInjectedConntectionString()
        {
            var fakeDatabaseSession = new Mock<IDatabaseSession>();
            var testRepository = new RepositoryFactory("myconnectionstring").GetInstanceOf<FakeRepository>(fakeDatabaseSession.Object);

            Assert.That(testRepository, Is.Not.Null);
        }
开发者ID:shizzlator,项目名称:Dazzle,代码行数:7,代码来源:RepositoryContainerTest.cs


示例19: ShouldCreateInstanceOfDesiredRepository

        public void ShouldCreateInstanceOfDesiredRepository()
        {
            var fakeDatabaseSession = new Mock<IDatabaseSession>();
            var testRepository = new RepositoryFactory().GetInstanceOf<FakeRepository>(fakeDatabaseSession.Object);

             Assert.That(testRepository, Is.Not.Null);
        }
开发者ID:shizzlator,项目名称:Dazzle,代码行数:7,代码来源:RepositoryContainerTest.cs


示例20: should_create_repository

 public void should_create_repository()
 {
     var mockFactory = new FakeMongoDatabaseFactory();
     var sut = new RepositoryFactory(mockFactory);
     var result = sut.Create<User>(new RepositoryOptions("lorem", "ipsum", "users"));
     result.Should().NotBeNull();
     result.CollectionName.ShouldBeEquivalentTo("users");
 }
开发者ID:alexestevam,项目名称:UsersVoice,代码行数:8,代码来源:RepositoryFactoryTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ReqlFunction1类代码示例发布时间:2022-05-24
下一篇:
C# RepositoryBrowser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap