/// <summary> /// Initializes a new instance of the <see cref="SingleThreadCharacter" /> class. /// </summary> /// <param name="cause"> Cause options. </param> /// <param name="behavior"> Behavior options. </param> /// <param name="shutdownTimeout"> Shutdown timeout. </param> public SingleThreadCharacter(ICause cause, IBehavior behavior, TimeSpan shutdownTimeout, ILog log = null) { if (cause == null) { throw new ArgumentNullException("cause"); } if (behavior == null) { throw new ArgumentNullException("behavior"); } this.log = log ?? new EmptyLog(); this.cause = cause; this.behavior = behavior; this.shutdownTimeout = shutdownTimeout; this.thread = new Thread(this.RunComponent) { IsBackground = true }; this.log.DebugFormat( "Starting a new thread for cause '{0}' and behavior '{1}'", this.cause.ToString(), this.behavior.ToString()); this.thread.Start(); }
/// <summary> /// Initializes a new instance of the <see cref="SingleTaskCharacter" /> class. /// </summary> /// <param name="cause"> The <see cref="ICause"/>. </param> /// <param name="behavior"> The <see cref="IBehavior"/>. </param> /// <param name="log"> The <see cref="ILog"/>. </param> public SingleTaskCharacter(ICause cause, IBehavior behavior, ILog log = null) { if (cause == null) { throw new ArgumentNullException("cause"); } if (behavior == null) { throw new ArgumentNullException("behavior"); } this.log = log ?? new EmptyLog(); this.cause = cause; this.behavior = behavior; this.log.DebugFormat( "Starting a new task for cause '{0}' and behavior '{1}'", this.cause.ToString(), this.behavior.ToString()); this.task = Task.Factory.StartNew( this.RunComponent, this.cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); }
/// <summary> /// Wrap with retry cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <param name="maxRetryAttempts"> Max retry attempts. </param> /// <param name="retryPeriodProvider"> Retry period provider. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithRetry( this ICause innerCause, int maxRetryAttempts, Func <int, TimeSpan> retryPeriodProvider = null) { return(new RetryWrapperCause(innerCause, maxRetryAttempts, retryPeriodProvider)); }
/// <summary> /// Wrap with function cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <param name="wrappingFunc"> Wrapping function. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithFunc(this ICause innerCause, Func <ICause, ICause> wrappingFunc) { if (wrappingFunc == null) { throw new ArgumentNullException("wrappingFunc"); } return(wrappingFunc(innerCause)); }
/// <summary> /// Initializes a new instance of the <see cref="AbstractWrapperCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> protected AbstractWrapperCause(ICause cause) { if (cause == null) { throw new ArgumentNullException("cause"); } this.InnerCause = cause; }
public ResetCard(CardInstance cardToReset, ICause cause) : base(cause) { if (cardToReset == null) { throw new ArgumentNullException("cardToReset"); } CardToReset = cardToReset; }
public DealDamageToCard(CardInstance target, int damageToDeal, ICause cause) : base(cause) { if (target == null) { throw new ArgumentNullException("target"); } Target = target; DamageToDeal = damageToDeal; }
public HealCard(CardInstance target, int lifeToHeal, ICause cause) : base(cause) { if (target == null) { throw new ArgumentNullException("target"); } Target = target; LifeToHeal = lifeToHeal; }
/// <summary> /// Add revolver chamber. /// </summary> /// <param name="cause"> Cause as a chamber. </param> public virtual void AddChamber(ICause cause) { lock (this.ChambersLock) { if (this.Chambers.Contains(cause)) { return; } this.Chambers.Add(cause); } }
public MoveCard(CardInstance subject, int toZone, ICause cause) : base(cause) { if (subject == null) { throw new ArgumentNullException("subject"); } m_fromZone = subject.Owner.m_zones.GetZone(subject.Zone); m_toZone = subject.Owner.m_zones.GetZone(toZone); Subject = subject; }
public DrawMove(Player player, int toZone, ICause cause) : base(cause) { if (player == null) { throw new ArgumentNullException("player"); } m_fromZone = player.m_zones.GetZone(SystemZone.Library); m_toZone = player.m_zones.GetZone(toZone); Subject = null; Player = player; }
public AdminController(IDonation donation, ILoanDonor loanDonor, IRecurringDonation recurringDonation, ILoan loan, IContact contact, IUserProfile userProfile, ICause cause, IReview review, IVolunteer volunteer, IConfiguration config, IHttpContextAccessor accessor) { _cause = cause; _recurringdonation = recurringDonation; _loan = loan; _loandonor = loanDonor; _volunteer = volunteer; _donation = donation; _contact = contact; _review = review; _userprofile = userProfile; _config = config; _accessor = accessor; }
/// <summary> /// Initializes a new instance of the <see cref="RetryWrapperCause" /> class. /// </summary> /// <param name="cause"> Cause to wrap. </param> /// <param name="maxRetryAttempts"> Max retry attempts. </param> /// <param name="retryPeriodProvider"> Retry period provider. </param> public RetryWrapperCause( ICause cause, int maxRetryAttempts, Func <int, TimeSpan> retryPeriodProvider = null) : base(cause) { if (maxRetryAttempts < 0) { throw new ArgumentOutOfRangeException( "maxRetryAttempts", "MaxRetryAttempts property value must be greater or equal to 0."); } this.maxRetryAttempts = maxRetryAttempts; this.retryPeriodProvider = retryPeriodProvider; }
public SubtractPlayerLife(Player player, int amount, bool ignoreModifiers, ICause cause) : base(cause) { if (player == null) { throw new ArgumentNullException("player"); } else if (amount < 0) { throw new ArgumentOutOfRangeException("amount", "Amount must be greater than or equal to zero."); } Player = player; Amount = amount; FinalAmount = ignoreModifiers ? amount : player.CalculateFinalLifeSubtract(amount); }
/// <summary> /// Initializes a new instance of the <see cref="PauseWrapperCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> /// <param name="periodSec"> Period to wait in seconds. </param> /// <param name="firstTimeExecute"> First time execute don't wait. </param> public PauseWrapperCause(ICause cause, double periodSec, bool firstTimeExecute = true) : base(cause) { this.periodMs = Convert.ToInt32(periodSec * 1000); if (this.periodMs <= 0) { throw new ArgumentOutOfRangeException("periodSec", "Value must be grater than zero"); } this.lastExecution = DateTime.UtcNow; if (firstTimeExecute) { this.lastExecution = this.lastExecution.Subtract(TimeSpan.FromMilliseconds(this.periodMs)); } }
public SummonMove(ICardModel model, Player owner, int toZone, ICause cause) : base(cause) { if (model == null) { throw new ArgumentNullException("model"); } else if (owner == null) { throw new ArgumentNullException("owner"); } m_toZone = owner.m_zones.GetZone(toZone); Subject = null; Model = model; Owner = owner; }
public ReviveMove(Player player, ICardModel cardToRevive, int fromZone, int toZone, ICause cause) : base(cause) { if (player == null) { throw new ArgumentNullException("player"); } else if (cardToRevive == null) { throw new ArgumentNullException("cardToRevive"); } m_fromZone = player.m_zones.GetZone(fromZone); m_toZone = player.m_zones.GetZone(toZone); Subject = null; Player = player; CardToRevive = cardToRevive; }
/// <summary> /// Initializes a new instance of the <see cref="TaskPoolCharacter" /> class. /// </summary> /// <param name="cause"> Cause. </param> /// <param name="behavior"> Behavior. </param> /// <param name="maxCount"> Maximum task count. </param> /// <param name="poolInterval"> Pool interval. </param> public TaskPoolCharacter(ICause cause, IBehavior behavior, int maxCount, TimeSpan poolInterval, ILog log = null) { if (cause == null) { throw new ArgumentNullException("cause"); } if (behavior == null) { throw new ArgumentNullException("behavior"); } if (maxCount <= 0) { throw new ArgumentOutOfRangeException("maxCount", "Max count must be grether than zero"); } this.log = log ?? new EmptyLog(); this.cause = cause; this.behavior = behavior; this.maxCount = maxCount; this.poolInterval = this.poolInterval.TotalMilliseconds < 100 ? new TimeSpan(0, 0, 0, 0, 100) : poolInterval; }
/// <summary> /// Wrap with exception suppressing cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithExceptionSuppressing(this ICause innerCause) { return(new ExceptionSuppressingWrapperCause(innerCause)); }
/// <summary> /// Initializes a new instance of the <see cref="RetryWrapperCause" /> class. /// </summary> /// <param name="cause"> Cause to wrap. </param> /// <param name="maxRetryAttempts"> Max retry attempts. </param> /// <param name="retryPeriod"> Retry period. </param> public RetryWrapperCause(ICause cause, int maxRetryAttempts, TimeSpan retryPeriod, ILog log = null) : this(cause, maxRetryAttempts, i => retryPeriod) { this.log = log ?? new EmptyLog(); }
/// <summary> /// Wrap with required cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <param name="poolPeriodSec"> Period to wait if previous data not found. </param> /// <param name="firstTimeExecute"> First time execute don't wait. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithPool(this ICause innerCause, double poolPeriodSec, bool firstTimeExecute = true) { return(new PoolWrapperCause(innerCause, poolPeriodSec, firstTimeExecute)); }
/// <summary> /// Initializes a new instance of the <see cref="DebugCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> /// <param name="name"> Name to print. </param> public DebugCause(ICause cause, string name = null, ILog log = null) : base(cause) { this.log = log ?? new EmptyLog(); this.name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name; }
/// <summary> /// Initializes a new instance of the <see cref="RequiredWrapperCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> public RequiredWrapperCause(ICause cause) : base(cause) { }
public CauseController(ICause cause, IConfiguration config, IHttpContextAccessor accessor) { _cause = cause; _config = config; _accessor = accessor; }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionSuppressingWrapperCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> public ExceptionSuppressingWrapperCause(ICause cause) : base(cause) { }
public InitiativeMoveCard(CardInstance subject, int toZone, ICause cause) : base(subject, toZone, cause) { }
public SubtractPlayerLife(Player player, int amount, ICause cause) : this(player, amount, false, cause) { }
/// <summary> /// Wrap with required cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithRequired(this ICause innerCause) { return(new RequiredWrapperCause(innerCause)); }
/// <summary> /// Initializes a new instance of the <see cref="BasicCharacter"/> class. /// </summary> /// <param name="cause"> Cause to check. </param> /// <param name="behavior"> Behavior to execute. </param> public BasicCharacter(ICause cause, IBehavior behavior) { this.cause = cause; this.behavior = behavior; }
/// <summary> /// Initializes a new instance of the <see cref="PoolWrapperCause" /> class. /// </summary> /// <param name="cause"> Inner cause. </param> /// <param name="poolPeriodSec"> Period to wait if effect is not returned. In seconds. </param> /// <param name="firstTimeExecute"> First time execute don't wait. </param> public PoolWrapperCause(ICause cause, double poolPeriodSec, bool firstTimeExecute = true) : base(cause, poolPeriodSec, firstTimeExecute) { // if first time to execute then set as previous data found. this.previousDataFound = firstTimeExecute; }
public AddPlayerMana(Player player, int amount, ICause cause) : this(player, amount, false, cause) { }
protected BaseCommand(ICause cause) { Cause = cause; }
/// <summary> /// Wrap with debug cause. /// </summary> /// <param name="innerCause"> Inner cause. </param> /// <param name="name"> Name to print. </param> /// <returns> Wrapped cause. </returns> public static ICause WrapWithDebug(this ICause innerCause, string name = null) { return(new DebugCause(innerCause, name)); }