Exemplo n.º 1
0
        public override string ToString()
        {
            if (Terms == null)
            {
                string termString = String.Format("{0}{{{1}}}:{2}", TermType.ToString().ToUpperInvariant(), String.Join(",", Values), String.Join(",", Fields.Select(field => field.Name)));
                if (Inverted.HasValue && Inverted.Value)
                {
                    termString = "(NOT+" + termString + ")";
                }
                return(termString);
            }

            var sb = new StringBuilder();

            sb.Append("(");
            foreach (var term in Terms)
            {
                if (term.Operator.HasValue)
                {
                    sb.Append("+" + term.Operator.ToString().ToUpperInvariant() + "+");
                }
                sb.Append(term);
            }
            sb.Append(")");

            return(sb.ToString());
        }
Exemplo n.º 2
0
        public List <Term> GetTerms(TermType type)
        {
            var request = _apiClient.CreateRequest("artist/list_terms");

            request.AddQueryParameter("type", type.ToString().ToLowerInvariant());
            var response = _apiClient.Execute <ArtistTermsResponse>(request);

            return(response.Terms);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Use resources to resolve the enum names.
 /// </summary>
 /// <returns></returns>
 public string GetLocalizedTermType()
 {
     return(typeof(TermType)
            .GetField(TermType.ToString())
            .GetCustomAttributes(typeof(DisplayAttribute), true)
            .Cast <DisplayAttribute>()
            .Single()
            .GetName());
 }
Exemplo n.º 4
0
        public List <Term> GetArtistTerms(string name, TermType type)
        {
            var request = _apiClient.CreateRequest("artist/terms");

            request.AddQueryParameter("name", name);
            request.AddQueryParameter("type", type.ToString());
            var response = _apiClient.Execute <ArtistTermsResponse>(request);

            return(response.Terms);
        }
Exemplo n.º 5
0
        public static HangmanObject GetTerm(TermType type)
        {
            var rng = new NadekoRandom();

            if (type == TermType.Random)
            {
                type = _termTypes[rng.Next(0, _termTypes.Length - 1)];
            }

            return(Data.TryGetValue(type.ToString(), out var termTypes) && termTypes.Length != 0
                                ? termTypes[rng.Next(0, termTypes.Length)]
                                : throw new TermNotFoundException(type));
        }
Exemplo n.º 6
0
        public static HangmanObject GetTerm(TermType type)
        {
            var rng = new NadekoRandom();

            if (type == TermType.Random)
            {
                var keys = Data.Keys.ToArray();

                type = _termTypes[rng.Next(0, _termTypes.Length - 1)]; // - 1 because last one is 'all'
            }
            if (!Data.TryGetValue(type.ToString(), out var termTypes) || termTypes.Length == 0)
            {
                throw new TermNotFoundException();
            }

            var obj = termTypes[rng.Next(0, termTypes.Length)];

            obj.Word = obj.Word.Trim().ToLowerInvariant();
            return(obj);
        }