-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #508 from Unengine/add-randomextension
Remove `IActionContext.NewGuid()` & Add `RandomExtension.GenerateRandomGuid()`
- Loading branch information
Showing
5 changed files
with
35 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System; | ||
|
||
namespace Libplanet.Action | ||
{ | ||
/// <summary> | ||
/// This extension class provides some convenient methods | ||
/// to deal with <see cref="IRandom"/>. | ||
/// </summary> | ||
public static class RandomExtension | ||
{ | ||
/// <summary> | ||
/// Generates a random <see cref="Guid"/>. | ||
/// </summary> | ||
/// <param name="random"> <see cref="IRandom"/> to generate | ||
/// a random <see cref="Guid"/>.</param> | ||
/// <returns> Generated random <see cref="Guid"/>. | ||
/// </returns> | ||
/// <seealso cref="IRandom"/> | ||
public static Guid GenerateRandomGuid(this IRandom random) | ||
{ | ||
// FIXME implement rfc4122 https://www.ietf.org/rfc/rfc4122.txt | ||
var bytes = new byte[16]; | ||
random.NextBytes(bytes); | ||
return new Guid(bytes); | ||
} | ||
} | ||
} |