public TConfig GetConfig() { if (!IsJsonConfig.GetOrAdd(typeof(TConfig), type => Attribute.IsDefined(type, typeof(JsonConfigAttribute)))) { return(Decoratee.GetConfig()); } foreach (var assembly in JsonConfigAssembliesProvider.GetAssemblies()) { foreach (var @namespace in JsonConfigNamespacesProvider.GetNamespaces(assembly)) { foreach (var configName in JsonConfigNamesProvider.GetConfigNames()) { var stream = assembly.GetManifestResourceStream($"{@namespace}.{configName}"); if (stream == null) { continue; } using (var reader = new StreamReader(stream)) { var json = reader.ReadToEnd(); var config = JsonConvert.DeserializeObject <TConfig>(json); if (config != null) { return(config); } } } } } return(Decoratee.GetConfig()); }
public override TOut Handle(TIn input) { var result = Decoratee.Handle(input); _logger.LogInformation($"{Decoratee.GetType().Name} : {input.ToString()} => {result.ToString()}"); return(result); }
public override TOut Handle(TIn input) { var result = Decoratee.Handle(input); _context.SaveChanges(); return(result); }
public TOutput Execute(TParam param) { Logger.LogInformation($"Executing command with parameter of type {param.GetType()}"); var result = Decoratee.Execute(param); return(result); }
public bool Remove(object key) { object item = Get(key); container.Remove(item); return(Decoratee.Remove(key)); }
protected override void DoStart() { isDecorateeDone = false; isDecorateeSuccess = false; isLimitReached = false; Clock.AddTimer(limit, randomVariation, 0, TimeoutReached); Decoratee.Start(); }
private void checkCondition() { if (condition.Invoke()) { Clock.RemoveTimer(checkCondition); Decoratee.Start(); } }
public EitherAsync <Error, TResponse> Execute(TParam param) { var logger = Log.ForContext(RootInstance.GetType()); logger.Debug("Executing query {@QueryParam}", param); var result = Decoratee.Execute(param) .Do(_ => logger.Debug("Query execution complete.")); return(result); }
public EitherAsync <Error, TResponse> Handle(TRequest request) { var logger = Log.ForContext(RootInstance.GetType()); logger.Debug("Handling request {@Request}", request); var result = Decoratee.Handle(request) .Do(_ => logger.Debug("Request handling complete.")); return(result); }
protected override void DoStart() { if (!condition.Invoke()) { Clock.AddTimer(checkInterval, checkVariance, -1, checkCondition); } else { Decoratee.Start(); } }
protected override void DoStart() { if (UnityEngine.Random.value <= this.probability) { Decoratee.Start(); } else { Stopped(false); } }
protected override void DoStart() { if (!condition.Invoke()) { Stopped(false); } else { Decoratee.Start(); } }
protected override void DoStart() { if (Mathf.Random() <= this.probability) { Decoratee.Start(); } else { Stopped(false); } }
override protected void DoCancel() { Clock.RemoveTimer(TimeoutReached); if (Decoratee.IsActive) { Decoratee.CancelWithoutReturnResult(); } else { Stopped(false); } }
override protected void DoStop() { Clock.RemoveTimer(checkCondition); if (Decoratee.IsActive) { Decoratee.Stop(); } else { Stopped(false); } }
private void TimeoutReached() { if (!waitForChildButFailOnLimitReached) { Decoratee.Stop(); } else { isLimitReached = true; Assert.IsTrue(Decoratee.IsActive); } }
override protected void DoStop() { Clock.RemoveTimer(TimeoutReached); if (Decoratee.IsActive) { Decoratee.Stop(); } else { Stopped(false); } }
private void TimeoutReached() { if (IsActive && !Decoratee.IsActive) { Clock.AddTimer(cooldownTime, randomVariation, 0, TimeoutReached); Decoratee.Start(); } else { isReady = true; } }
protected override void DoStart() { if (isReady) { isReady = false; if (!startAfterDecoratee) { Clock.AddTimer(cooldownTime, randomVariation, 0, TimeoutReached); } Decoratee.Start(); } }
private void TimeoutReached() { if (!waitForChildButFailOnLimitReached) { Decoratee.CancelWithoutReturnResult(); } else { isLimitReached = true; Debug.Assert(Decoratee.IsActive); } }
protected override void DoStart() { if (loopCount != 0) { currentLoop = 0; Decoratee.Start(); } else { this.Stopped(true); } }
public EitherAsync <Error, TResponse> Handle(TRequest request) { var featureEnabled = GetFeatureInfo(RootInstance) .MapAsync(async fi => await _featureManager.IsEnabledAsync(fi.Action, fi.Context)).Map(p => p.Match( Right: enabled => enabled ? (Either <Error, Unit>)Unit.Default : Error.FeatureDisabled(), Left: e => e )) .ToAsync(); return(featureEnabled.Bind(_ => Decoratee.Handle(request))); }
protected override void DoStart() { if (repeatTimes != 0) { stopRequested = false; numberOfExecutions = 0; Decoratee.Start(); } else { this.Stopped(true); } }
override protected void DoStop() { this.Clock.RemoveTimer(restartDecoratee); if (Decoratee.IsActive) { Decoratee.Stop(); } else { Stopped(false); } }
override protected void DoCancel() { this.Clock.RemoveTimer(restartDecoratee); if (Decoratee.IsActive) { Decoratee.CancelWithoutReturnResult(); } else { Stopped(false); } }
public EitherAsync <Error, TResponse> Handle(TRequest request) { var permissionEnabled = ExtractPermissionToCheck(RootInstance) .MapAsync(async perm => await _authZService.CheckAccess(perm)) .Map(p => p.Match( Right: allowed => allowed ? (Either <Error, Unit>)Unit.Default : Error.NotAuthorized("No permission"), Left: e => e )) .ToAsync(); return(permissionEnabled.Bind(_ => Decoratee.Handle(request))); }
protected override void DoStop() { Clock.RemoveTimer(CheckQuorum); Clock.RemoveTimer(QuorumNotMet); RootNode.Blackboard.Get <Agent>("self").EnableCheckMailbox(); if (Decoratee.IsActive) { Decoratee.Stop(); } else { Stopped(false); } }
public override List <Message> GetMessages() { List <Message> newMessageQueue = new List <Message>(); foreach (var message in Decoratee.GetMessages()) { var cipherText = $"<Зашифровано> {message.GetText()} </Зашифровано>"; var newMessage = new Message(message.GetAuthor(), message.GetRecipient(), cipherText); newMessageQueue.Add(newMessage); } return(newMessageQueue); }
protected override bool HandleCallback( object callback, bool greedy, IHandler composer) { var composition = callback as Composition; var options = (composition?.Callback ?? callback) as T; var handled = options != null; if (handled) { _options.MergeInto(options); } return(handled && !greedy || (Decoratee.Handle(callback, greedy, composer) || handled)); }
public override TOut Handle(TIn input) { _timer.Start(); var result = Decoratee.Handle(input); _timer.Stop(); if (_timer.ElapsedMilliseconds > 500) { _logger.LogWarning($"Долгий запрос: {typeof(TIn).Name} = {_timer.ElapsedMilliseconds} milliseconds"); } return(result); }