示例#1
0
 // Using a Singleton pattern because the Random class should not be instantiated in quick succession:
 // https://docs.microsoft.com/en-us/dotnet/api/system.random?view=netcore-3.1#instantiating-the-random-number-generator
 public static DiceRollService GetInstance()
 {
     if (_instance == null)
     {
         _instance = new DiceRollService();
     }
     return(_instance);
 }
示例#2
0
 public HitDiceService(DiceRollService diceRollService = null)
 {
     _diceRollService = diceRollService != null ? diceRollService : DiceRollService.GetInstance();
 }