Esempio n. 1
0
        /// <summary>Retrieve all genres.</summary>
        public async Task <GenresResponse> GetGenresAsync(bool ignorearticle    = false,
                                                          SortMethod sortMethod = SortMethod.none,
                                                          SortOrder sortOrder   = SortOrder.Ascending,
                                                          int start             = 0, int end = int.MaxValue,
                                                          params LibraryFieldsGenre[] fields)
        {
            string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray();

            if (!properties.Any())
            {
                properties = Enum.GetNames(typeof(LibraryFieldsGenre));
            }

            var method = new ParameteredMethodMessage <LimitsSortPropertiesParameters>
            {
                Method     = "AudioLibrary.GetGenres",
                Parameters = new LimitsSortPropertiesParameters
                {
                    Properties = properties,
                    Limits     = new ListLimits {
                        Start = start, End = end
                    },
                    Sort = new ListSort
                    {
                        IgnoreArticle = ignorearticle,
                        Order         = sortOrder.ToString().ToLowerInvariant(),
                        Method        = sortMethod.ToString().ToLowerInvariant()
                    }
                }
            };

            var result = await _request.SendRequestAsync <BasicResponseMessage <GenresResponse> >(method);

            return(result.Result);
        }
Esempio n. 2
0
 public static void PrintSortedRecords(SortMethod method, IList <Record> records)
 {
     Console.WriteLine("Printing all records sorted using the " + method.ToString() + " method...\n");
     Console.WriteLine("+======================================================================================================+");
     foreach (Record record in records)
     {
         PrintSingleRecord(record);
     }
     Console.WriteLine("+======================================================================================================+");
 }
Esempio n. 3
0
        public int CompareTo(object obj)
        {
            int result = 0;

            try
            {
                if (obj is EligibleHomeSite)
                {
                    EligibleHomeSite other = (EligibleHomeSite)obj;
                    switch (_sortOrder)
                    {
                    //because the default is asscending order we do it backwards to get descending order
                    case SortMethod.Food:
                        result = other.Food.CompareTo(mFood);
                        break;

                    case SortMethod.Risk:
                        result = other.Risk.CompareTo(mRisk);
                        break;

                    case SortMethod.Rank:
                        result = other.Rank.CompareTo(mRank);
                        break;

                    case SortMethod.Dist:
                        result = other.DistanceFromCurrLocation.CompareTo(mDistanceFromCurrLocation);
                        break;

                    default:
                        throw new System.Exception(_sortOrder.ToString() + " is bad Sort Method for EligibleHomeSite");
                    }
                }
                else
                {
                    throw new ArgumentException("Object is not an EligibleHomeSite");
                }
            }
            catch (System.Exception ex)
            {
#if (DEBUG)
                System.Windows.Forms.MessageBox.Show(ex.Message);
#endif
                eLog.Debug(ex);
            }
            return(result);
        }
Esempio n. 4
0
        public static void Write()
        {
            config.SetBool("PP Helper", "showInfo", showInfo);
            config.SetFloat("PP Helper", "defaultAcc", defaultAcc);
            config.SetBool("PP Helper", "ppTop", ppTop);
            config.SetFloat("PP Helper", "accIncrement", accIncrement);
            config.SetFloat("PP Helper", "starRange", starRange);
            config.SetString("PP Helper", "starAccChoice", starAccChoice.ToString());
            config.SetInt("PP Helper", "numberOfScores", numberOfScores);
            config.SetBool("PP Helper", "accOverride", accOverride);
            config.SetBool("PP Helper", "autoUpdate", autoUpdate);
            config.SetBool("PP Helper", "playHistory", playHistory);
            config.SetString("PP Helper", "sortMethod", sortMethod.ToString());

            config.SetBool("PP Helper", "ignoreNoFail", ignoreNoFail);
            config.SetBool("PP Helper", "hideOnStart", hideOnStart);
            config.SetInt("PP Helper", "decimalPrecision", decimalPrecision);
        }
 public void PerformanceAnalyzer(SortMethod method, int testRound = 100)
 {
     if (method == SortMethod.quickSort)
     {
         _sorter = new Sorter(quickSort);
     }
     else if (method == SortMethod.randomizedQuicksort)
     {
         _sorter = new Sorter(rQuickSort);
     }
     else if (method == SortMethod.improvedQuicksort)
     {
         _sorter = new Sorter(improvedQuicksort);
     }
     else
     {
         _sorter = new Sorter(rImprovedQuicksort);
     }
     Console.WriteLine("Testing {0} method for {1} rounds", method.ToString(), testRound);
     _performanceAnalyzer(testRound);
 }
Esempio n. 6
0
        private async Task <T> GetAsync <T, TEnum>(string methodName, bool ignorearticle,
                                                   Filter filter,
                                                   SortMethod sortMethod,
                                                   SortOrder sortOrder,
                                                   int start, int end,
                                                   IEnumerable <TEnum> fields)
        {
            string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray();

            if (!properties.Any())
            {
                properties = Enum.GetNames(typeof(TEnum));
            }

            var method = new ParameteredMethodMessage <FilteredPropertiesParameters>
            {
                Method     = methodName,
                Parameters = new FilteredPropertiesParameters
                {
                    Filter     = filter,
                    Properties = properties,
                    Limits     = new ListLimits {
                        Start = start, End = end
                    },
                    Sort = new ListSort
                    {
                        IgnoreArticle = ignorearticle,
                        Order         = sortOrder.ToString().ToLowerInvariant(),
                        Method        = sortMethod.ToString().ToLowerInvariant()
                    }
                }
            };

            var result = await _request.SendRequestAsync <BasicResponseMessage <T> >(method);

            return(result.Result);
        }
Esempio n. 7
0
        private async Task <T> GetFilteredAlbumsSongsAsync <T, E>(string methodName,
                                                                  bool ignorearticle,
                                                                  SortMethod sortMethod,
                                                                  SortOrder sortOrder,
                                                                  int start, int end,
                                                                  IEnumerable <E> fields,
                                                                  int?artistId = null,
                                                                  int?albumId  = null,
                                                                  int?genreId  = null)
        {
            string[] properties = fields.Select(p => p.ToString().ToLowerInvariant()).ToArray();

            if (!properties.Any())
            {
                properties = Enum.GetNames(typeof(E));
            }

            Filter filter = null;

            if (artistId != null)
            {
                filter = new Filter {
                    ArtistId = artistId
                }
            }
            ;

            if (albumId != null)
            {
                filter = new Filter {
                    AlbumId = albumId
                }
            }
            ;

            if (genreId != null)
            {
                filter = new Filter {
                    GenreId = genreId
                }
            }
            ;

            var method = new ParameteredMethodMessage <FilteredPropertiesParameters>
            {
                Method     = methodName,
                Parameters = new FilteredPropertiesParameters
                {
                    Filter     = filter,
                    Properties = properties,
                    Limits     = new ListLimits {
                        Start = start, End = end
                    },
                    Sort = new ListSort
                    {
                        IgnoreArticle = ignorearticle,
                        Order         = sortOrder.ToString().ToLowerInvariant(),
                        Method        = sortMethod.ToString().ToLowerInvariant()
                    }
                }
            };

            var result = await _request.SendRequestAsync <BasicResponseMessage <T> >(method);

            return(result.Result);
        }