本文整理汇总了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();
}
示例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;
}
示例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;
}
}
示例4: GetCurrentSeason
public Season GetCurrentSeason()
{
using (var seasonRepository = new RepositoryFactory().CreateSeasonRepository())
{
return seasonRepository.GetCurrentSeason(Game.Id);
}
}
示例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;
}
示例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();
}
}
}
}
示例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;
}
示例8: GetUser
public User GetUser(string username, string password)
{
using (var userRepository = new RepositoryFactory().CreateUserRepository())
{
return userRepository.GetByUsernameAndPassword(username, password);
}
}
示例9: GetNextMatchDay
public DateTime GetNextMatchDay(string seasonId)
{
using (var matchRepository = new RepositoryFactory().CreateMatchRepository())
{
return matchRepository.GetNextMatchDay(seasonId);
}
}
示例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;
}
}
示例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);
}
示例12: GetByRound
public IEnumerable<Match> GetByRound(Round round)
{
using (var matchRepository = new RepositoryFactory().CreateMatchRepository())
{
return matchRepository.GetByRound(round.Id);
}
}
示例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);
}
}
}
}
}
示例14: GetMyTeam
public Team GetMyTeam(Game game)
{
using (var teamRepository = new RepositoryFactory().CreateTeamRepository())
{
return teamRepository.GetTeam(game.CurrentTeamId);
}
}
示例15: Get
public Season Get(string seasonId)
{
using (var seasonRepository = new RepositoryFactory().CreateSeasonRepository())
{
return seasonRepository.GetOne(seasonId);
}
}