Пример #1
0
        public virtual async Task <bool> GetRatings(BufferBlock <BasicInfo> entitiesInfoQueue,
                                                    BufferBlock <RatingDataContainer> entitiesRatingQueue, bool outputResults)
        {
            while (await entitiesInfoQueue.OutputAvailableAsync())
            {
                BasicInfo entityInfo = await entitiesInfoQueue.ReceiveAsync();

                var resultInfo = new RatingDataContainer(entityInfo, entityInfo.VoteAverage);
                await entitiesRatingQueue.SendAsync(resultInfo);

                if (outputResults)
                {
                    GlobalMessageHandler.OutputMessage(resultInfo.ToString());
                }
            }
            return(true);
        }
Пример #2
0
        public RatingDataContainer GetRatings(BasicInfo entityInfo, bool outputResults)
        {
            if (!(entityInfo is T convertedInfo))
            {
                throw new ArgumentException(
                          $"Element \"{entityInfo.Title}\" (ID = {entityInfo.ThingId.ToString()}) " +
                          $"type \"{entityInfo.GetType().FullName}\" is invalid for appraiser with " +
                          $"type \"{TypeId.FullName}\"."
                          );
            }

            double ratingValue = _appraisal.CalculateRating(convertedInfo);

            var resultInfo = new RatingDataContainer(entityInfo, ratingValue, RatingId);

            if (outputResults)
            {
                GlobalMessageHandler.OutputMessage(resultInfo.ToString());
            }

            return(resultInfo);
        }