コード例 #1
0
ファイル: JsonConfigProvider.cs プロジェクト: IgoR-NiK/Aqua
        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());
        }
コード例 #2
0
        public override TOut Handle(TIn input)
        {
            var result = Decoratee.Handle(input);

            _logger.LogInformation($"{Decoratee.GetType().Name} : {input.ToString()} => {result.ToString()}");
            return(result);
        }
コード例 #3
0
        public override TOut Handle(TIn input)
        {
            var result = Decoratee.Handle(input);

            _context.SaveChanges();
            return(result);
        }
コード例 #4
0
        public TOutput Execute(TParam param)
        {
            Logger.LogInformation($"Executing command with parameter of type {param.GetType()}");
            var result = Decoratee.Execute(param);

            return(result);
        }
コード例 #5
0
ファイル: LifetimeLocator.cs プロジェクト: punker76/Umbrella
        public bool Remove(object key)
        {
            object item = Get(key);

            container.Remove(item);

            return(Decoratee.Remove(key));
        }
コード例 #6
0
 protected override void DoStart()
 {
     isDecorateeDone    = false;
     isDecorateeSuccess = false;
     isLimitReached     = false;
     Clock.AddTimer(limit, randomVariation, 0, TimeoutReached);
     Decoratee.Start();
 }
コード例 #7
0
 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);
        }
コード例 #10
0
 protected override void DoStart()
 {
     if (!condition.Invoke())
     {
         Clock.AddTimer(checkInterval, checkVariance, -1, checkCondition);
     }
     else
     {
         Decoratee.Start();
     }
 }
コード例 #11
0
ファイル: Random.cs プロジェクト: Hadzabadza/Tanks
 protected override void DoStart()
 {
     if (UnityEngine.Random.value <= this.probability)
     {
         Decoratee.Start();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #12
0
 protected override void DoStart()
 {
     if (!condition.Invoke())
     {
         Stopped(false);
     }
     else
     {
         Decoratee.Start();
     }
 }
コード例 #13
0
 protected override void DoStart()
 {
     if (Mathf.Random() <= this.probability)
     {
         Decoratee.Start();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #14
0
 override protected void DoCancel()
 {
     Clock.RemoveTimer(TimeoutReached);
     if (Decoratee.IsActive)
     {
         Decoratee.CancelWithoutReturnResult();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #15
0
 override protected void DoStop()
 {
     Clock.RemoveTimer(checkCondition);
     if (Decoratee.IsActive)
     {
         Decoratee.Stop();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #16
0
 private void TimeoutReached()
 {
     if (!waitForChildButFailOnLimitReached)
     {
         Decoratee.Stop();
     }
     else
     {
         isLimitReached = true;
         Assert.IsTrue(Decoratee.IsActive);
     }
 }
コード例 #17
0
 override protected void DoStop()
 {
     Clock.RemoveTimer(TimeoutReached);
     if (Decoratee.IsActive)
     {
         Decoratee.Stop();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #18
0
ファイル: Cooldown.cs プロジェクト: Aetulier/Unity3D_ARPGDemo
 private void TimeoutReached()
 {
     if (IsActive && !Decoratee.IsActive)
     {
         Clock.AddTimer(cooldownTime, randomVariation, 0, TimeoutReached);
         Decoratee.Start();
     }
     else
     {
         isReady = true;
     }
 }
コード例 #19
0
 protected override void DoStart()
 {
     if (isReady)
     {
         isReady = false;
         if (!startAfterDecoratee)
         {
             Clock.AddTimer(cooldownTime, randomVariation, 0, TimeoutReached);
         }
         Decoratee.Start();
     }
 }
コード例 #20
0
 private void TimeoutReached()
 {
     if (!waitForChildButFailOnLimitReached)
     {
         Decoratee.CancelWithoutReturnResult();
     }
     else
     {
         isLimitReached = true;
         Debug.Assert(Decoratee.IsActive);
     }
 }
コード例 #21
0
ファイル: Repeater.cs プロジェクト: agarzonp/Tanks
 protected override void DoStart()
 {
     if (loopCount != 0)
     {
         currentLoop = 0;
         Decoratee.Start();
     }
     else
     {
         this.Stopped(true);
     }
 }
コード例 #22
0
        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)));
        }
コード例 #23
0
 protected override void DoStart()
 {
     if (repeatTimes != 0)
     {
         stopRequested      = false;
         numberOfExecutions = 0;
         Decoratee.Start();
     }
     else
     {
         this.Stopped(true);
     }
 }
コード例 #24
0
ファイル: Repeater.cs プロジェクト: agarzonp/Tanks
        override protected void DoStop()
        {
            this.Clock.RemoveTimer(restartDecoratee);

            if (Decoratee.IsActive)
            {
                Decoratee.Stop();
            }
            else
            {
                Stopped(false);
            }
        }
コード例 #25
0
        override protected void DoCancel()
        {
            this.Clock.RemoveTimer(restartDecoratee);

            if (Decoratee.IsActive)
            {
                Decoratee.CancelWithoutReturnResult();
            }
            else
            {
                Stopped(false);
            }
        }
コード例 #26
0
        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)));
        }
コード例 #27
0
 protected override void DoStop()
 {
     Clock.RemoveTimer(CheckQuorum);
     Clock.RemoveTimer(QuorumNotMet);
     RootNode.Blackboard.Get <Agent>("self").EnableCheckMailbox();
     if (Decoratee.IsActive)
     {
         Decoratee.Stop();
     }
     else
     {
         Stopped(false);
     }
 }
コード例 #28
0
        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);
        }
コード例 #29
0
ファイル: Options.cs プロジェクト: michaellperry/Miruken
        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));
        }
コード例 #30
0
        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);
        }