Esempio n. 1
0
        private IEnumerable <KeyValuePair <string, string> > Process(SorterType type)
        {
            var results = WithSorter(type, _text).Sort();
            var pairs   = new List <KeyValuePair <string, string> >();

            foreach (var result in results)
            {
                pairs.Add(new KeyValuePair <string, string>(result, type.ToString()));
            }

            return(pairs);
        }
Esempio n. 2
0
        private ISorter WithSorter(SorterType sortertype, string[] text)
        {
            var sorter = _sorters.SingleOrDefault(q => q.GetType().GetAttributeType().Equals(sortertype));

            if (sorter == null)
            {
                throw new UnknownSorterException(sortertype.ToString());
            }

            sorter.Text = text.CleanText();

            return(sorter);
        }
Esempio n. 3
0
        public IEnumerable <KeyValuePair <string, string> > WithSorter(SorterType sortType)
        {
            if (sortType == SorterType.All)
            {
                var result = new List <KeyValuePair <string, string> >();
                var types  = Enum.GetValues(typeof(SorterType)).Cast <SorterType>().Where(q => q != SorterType.All).ToList();

                types.ForEach(type => result.AddRange(Process(type)));

                return(result);
            }

            return(Process(sortType));
        }
Esempio n. 4
0
        public Sorter(string @string)
        {
            if (@string.Substring(0, 1) == ">")
            {
                type = SorterType.GREATERTHAN;
            }
            else if (@string.Substring(0, 1) == "<")
            {
                type = SorterType.LESSTHAN;
            }
            else
            {
                throw new NotImplementedException();
            }

            value = int.Parse(@string.Substring(1));
        }
Esempio n. 5
0
    private Sorter GetSorter(SorterType type)
    {
        Sorter sorter = null;

        switch (type)
        {
        case SorterType.Bubble:
            sorter = new BubbleSorter();
            break;

        case SorterType.Bucket:
            sorter = new BucketSorter();
            break;

        case SorterType.Quick:
            sorter = new QuickSorter();
            break;
        }
        return(sorter);
    }