wip
This commit is contained in:
parent
def7767b94
commit
8ad4302ec8
13 changed files with 3902 additions and 4 deletions
18
Femto.Modules.Blog/Emoji/GetRandomEmoji.cs
Normal file
18
Femto.Modules.Blog/Emoji/GetRandomEmoji.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
namespace Femto.Modules.Blog.Emoji;
|
||||
|
||||
internal static partial class AllEmoji
|
||||
{
|
||||
public static IList<string> GetRandomEmoji(int count) => new Random().TakeRandomly(Emojis).Distinct().Take(count).ToList();
|
||||
}
|
||||
|
||||
internal static class RandomExtensions
|
||||
{
|
||||
public static IEnumerable<T> TakeRandomly<T>(this Random rand, ICollection<T> collection)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var idx = rand.Next(collection.Count);
|
||||
yield return collection.ElementAt(idx);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue