private IEnumerable <string> UseCaseSettings(IEnumerable <string> input, ICircularCloudLayouterWithWordsSettings settings)
 {
     if (settings.UpperCase)
     {
         return(input.Select(y => y.ToUpper()));
     }
     return(input.Select(y => y.ToLower()));
 }
Example #2
0
        public CloudWithWordsPainter(IImageHolder imageHolder,
                                     ICircularCloudLayouterWithWordsSettings settings, IPalette palette, ICircularCloudLayouter layouter,
                                     Dictionary <string, int> words)
        {
            this.imageHolder = imageHolder;
            this.settings    = settings;
            this.palette     = palette;
            this.layouter    = layouter;
            this.words       = words;

            imageSize = imageHolder.GetImageSize();
        }
 public CloudWithWordsPainterFactory(IImageHolder imageHolder,
                                     IPalette palette,
                                     ICircularCloudLayouterWithWordsSettings settings,
                                     ITextReader textReader,
                                     Func <Point, ICircularCloudLayouter> makeLayouter, IWordsFilter[] filters, IWordsFrequencyParser parser)
 {
     this.imageHolder  = imageHolder;
     this.palette      = palette;
     this.makeLayouter = makeLayouter;
     this.settings     = settings;
     this.filters      = filters;
     this.parser       = parser;
     this.textReader   = textReader;
 }
Example #4
0
 public void SetUp()
 {
     imageHolder = A.Fake <IImageHolder>();
     settings    = A.Fake <ICircularCloudLayouterWithWordsSettings>();
     palette     = A.Fake <IPalette>();
     layouter    = A.Fake <ICircularCloudLayouter>();
     graphics    = A.Fake <IGraphicDrawer>();
     A.CallTo(() => imageHolder.GetImageSize()).Returns(new Size(600, 600));
     A.CallTo(() => imageHolder.StartDrawing()).Returns(graphics);
     A.CallTo(() => settings.CenterX).Returns(300);
     A.CallTo(() => settings.Scale).Returns(5);
     A.CallTo(() => settings.CenterY).Returns(300);
     A.CallTo(() => palette.PrimaryColor).Returns(Color.Black);
     A.CallTo(() => palette.BackgroundColor).Returns(Color.Black);
     A.CallTo(() => palette.SecondaryColor).Returns(Color.Black);
 }
Example #5
0
        public Result <IEnumerable <string> > Filter(ICircularCloudLayouterWithWordsSettings settings, IEnumerable <string> words)
        {
            HashSet <string> partOfSpeechToFilter;

            try
            {
                var settingsFilename = settings.PartOfSpeechToFilterFile;
                partOfSpeechToFilter = File.ReadAllLines(settingsFilename).ToHashSet(StringComparer.OrdinalIgnoreCase);
            }
            catch (FileNotFoundException)
            {
                return(new Result <IEnumerable <string> >("Не удалось загрузить файл с part of speech to filter: файл отсутствует", words));
            }
            catch (Exception e)
            {
                return(new Result <IEnumerable <string> >("Не удалось загрузить файл с part of speech to filter: " + e.Message, words));
            }

            return(Filter(partOfSpeechToFilter, words));
        }
Example #6
0
        public Result <IEnumerable <string> > Filter(ICircularCloudLayouterWithWordsSettings settings,
                                                     IEnumerable <string> words)
        {
            HashSet <string> boringWords;

            try
            {
                var settingsFilename = settings.BoringWordsFile;
                boringWords = File.ReadAllLines(settingsFilename).ToHashSet(StringComparer.OrdinalIgnoreCase);
            }
            catch (FileNotFoundException)
            {
                return(new Result <IEnumerable <string> >("Не удалось загрузить файл с boring words: файл отсутствует",
                                                          words));
            }
            catch (Exception e)
            {
                return(new Result <IEnumerable <string> >("Не удалось загрузить файл с boring words: " + e.Message, words));
            }

            return(Filter(boringWords, words));
        }
Example #7
0
 public Result <IEnumerable <string> > Filter(ICircularCloudLayouterWithWordsSettings settings, IEnumerable <string> words)
 {
     return(Filter(words, settings.Language));
 }