本文整理汇总了C#中IIdGenerator.NextId方法的典型用法代码示例。如果您正苦于以下问题:C# IIdGenerator.NextId方法的具体用法?C# IIdGenerator.NextId怎么用?C# IIdGenerator.NextId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IIdGenerator
的用法示例。
在下文中一共展示了IIdGenerator.NextId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StatsModule
public StatsModule(ITemplate tmpl, IIdGenerator idgen, SavegameStorage storage)
{
Post["/games"] = _ =>
{
// Get the temporary location of the file on the server
var file = Request.Headers["X-FILE"].FirstOrDefault();
// Get the extension of the file when it was uploaded as the
// temporary file doesn't have an extension
var extension = Request.Headers["X-FILE-EXTENSION"].FirstOrDefault();
if (file == null)
throw new ArgumentException("File can't be null");
if (extension == null)
throw new ArgumentException("File extension can't be null");
Save savegame;
using (var stream = getStream(file, extension))
using (parsingTimer.NewContext())
savegame = new Save(stream);
// Turn the savegame into html and return the url for it
var stats = statsTimer.Time(() => Aggregate(savegame));
string contents = templateTimer.Time(() => tmpl.Render(stats));
string id = idgen.NextId();
return storage.Store(contents, id);
};
}
示例2: Build
public static Weapon Build(IIdGenerator idGenerator, WeaponInfo weaponInfo)
{
var id = idGenerator.NextId();
return Build(id, weaponInfo);
}