コード例 #1
0
ファイル: SortingService.cs プロジェクト: Iroki/AnimalApp
        public List <Animal> SortingSelection(List <Animal> createdAnimalList, SortingTypeEnum type)
        {
            switch (type)
            {
            case SortingTypeEnum.ByName:
                return(SortByName(createdAnimalList));

            case SortingTypeEnum.BySpecies:
                return(SortBySpecies(createdAnimalList));

            case SortingTypeEnum.ByPetname:
                return(SortByPetname(createdAnimalList));

            case SortingTypeEnum.ByAge:
                return(SortByAge(createdAnimalList));

            case SortingTypeEnum.ByPopulation:
                return(SortByPopulation(createdAnimalList));

            case SortingTypeEnum.ByEndangered:
                return(SortByEndangered(createdAnimalList));

            default:
                return(createdAnimalList);
            }
        }
コード例 #2
0
ファイル: SortingService.cs プロジェクト: Iroki/AnimalApp
        };                                                                                                                                                                                                                                                         //OR THE SAME: Enum.GetValues(typeof(SortingType)).Cast<SortingType>().ToList();

        public string ConvertEnumToString(SortingTypeEnum sortingType)
        {
            switch (sortingType)
            {
            case SortingTypeEnum.ByName:
                return("Sort by name");

            case SortingTypeEnum.BySpecies:
                return("Sort by species");

            case SortingTypeEnum.ByPetname:
                return("Sort by petname");

            case SortingTypeEnum.ByAge:
                return("Sort by age");

            case SortingTypeEnum.ByPopulation:
                return("Sort by population");

            case SortingTypeEnum.ByEndangered:
                return("Sort by endangered");

            default:
                return(String.Empty);
            }
        }