Beispiel #1
0
        TargetScore IScorable <Item, TargetScore> .GetScore(Item item, object state)
        {
            IScorable <Item, SourceScore> source = this.inner;
            var sourceScore = source.GetScore(item, state);
            var targetScore = this.selector(item, sourceScore);

            return(targetScore);
        }
Beispiel #2
0
        /// <summary>
        /// Invoke the scorable calling protocol against a single scorable.
        /// </summary>
        public static async Task <bool> TryPostAsync <Item, Score>(this IScorable <Item, Score> scorable, Item item, CancellationToken token)
        {
            var state = await scorable.PrepareAsync(item, token);

            if (scorable.HasScore(item, state))
            {
                var score = scorable.GetScore(item, state);
                await scorable.PostAsync(item, state, token);

                return(true);
            }

            return(false);
        }