18 lines
502 B
C#
18 lines
502 B
C#
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);
|
|
}
|
|
}
|
|
}
|