本文整理汇总了C#中IDatabase.GetGameByKey方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabase.GetGameByKey方法的具体用法?C# IDatabase.GetGameByKey怎么用?C# IDatabase.GetGameByKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDatabase
的用法示例。
在下文中一共展示了IDatabase.GetGameByKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GameModule
protected GameModule( IDatabase database )
: base("{gameKey}/")
{
Before.AddItemToStartOfPipeline( context =>
{
var gameKey = (string)context.Parameters.gameKey;
game = database.GetGameByKey( gameKey );
context.ViewBag[ViewBagKeys.CurrentGame] = game;
return null;
} );
}
示例2: MatchupModule
public MatchupModule( IDatabase database, Settings settings, IEnumerable<IMatchupProposer> proposers )
: base(database)
{
this.proposers = proposers.ToArray();
Get[Route.FindTeams] = o =>
{
var model = new FindTeamsModel()
{
Game = game,
AvailablePlayers = database.GetPlayersForGame( game.Id ).OrderBy( player => player.Name ).ToArray(),
AlgorithmName = App.MatchupProposer.GetType().Name,
};
return View[Route.FindTeams, model];
};
Get[Route.SetMatchupProposer] = o =>
{
var model = new SetMatchupProposerViewModel( proposers, App.MatchupProposer );
return View[Route.SetMatchupProposer, model];
};
Post[Route.SetMatchupProposer] = o =>
{
var request = this.Bind<SetMatchupProposerRequest>();
var matchupProposer = GetAlgorithm( request.SelectedAlgorithmTypeName );
App.MatchupProposer = matchupProposer;
return Response.AsRedirect( Route.FindTeams );
};
Get[Route.GetProposedMatchups] = o =>
{
var request = this.Bind<GetProposedMatchupsRequest>();
var proposer = App.MatchupProposer;
var response = new GetProposedMatchupsResponse();
try
{
var gameKey = (string)o.gameKey;
var game = database.GetGameByKey( gameKey );
if ( null == request.PlayerIds || request.PlayerIds.Count < 2 )
{
throw new Exception( "Two or more players must be selected" );
}
var players = request.PlayerIds.Select( database.GetUserById ).ToArray();
var proposedMatchups = proposer.GetMatchups( game, players ).OrderBy( matchup => matchup.Imbalance ).ToArray();
proposedMatchups = CleanUp( proposedMatchups );
response.ProposedMatchups = proposedMatchups;
}
catch ( Exception e )
{
response.ErrorMessage = e.Message;
}
return View[Route.GetProposedMatchups, response];
};
Post[Route.PresentMatchupForSaving] = o =>
{
var json = (string)Request.Form.matchup;
var matchup = json.FromJson<ProposedMatchup>();
return View[Route.SaveMatchupResult, new SaveMatchupResultViewModel(matchup, database.GetMaps(matchup.Game.Id))];
};
Post[Route.SaveMatchupResult] = o =>
{
var result = this.Bind<MatchupResult>();
database.SaveMatchupResult( result );
return Response.AsRedirect( Route.ViewResults );
};
Get[Route.ViewResults] = o =>
{
var game = database.GetGameByKey( o.gameKey );
var matchupResults = database.GetMatchupResultsByGame( game.Id );
var userMap = new IdentityMap<User>( database.GetUserById );
var model = new List<MatchupResultViewModel>();
foreach ( var matchupResult in matchupResults )
{
var map = database.GetMapById(matchupResult.MapId);
model.Add(new MatchupResultViewModel(matchupResult, userMap, map));
}
return View[Route.ViewResults, model];
};
Get[Route.SelectPlayers] = o =>
//.........这里部分代码省略.........