Пример #1
0
        public static apiType GetApiType(this suffix enumVal)
        {
            var     typeInfo = enumVal.GetType().GetTypeInfo();
            var     v        = typeInfo.DeclaredMembers.First(x => x.Name == enumVal.ToString());
            apiType a        = v.GetCustomAttribute <ApiTypeAttribute>().ApiType;

            return(a);
        }
Пример #2
0
        public static apiVer GetApiGroup(this suffix enumVal)
        {
            var    typeInfo = enumVal.GetType().GetTypeInfo();
            var    v        = typeInfo.DeclaredMembers.First(x => x.Name == enumVal.ToString());
            apiVer y        = v.GetCustomAttribute <apiVerAttribute>().ApiVer;

            return(y);
        }
Пример #3
0
 /// <summary>
 /// url formatter
 /// </summary>
 /// <param name="_suffix">
 /// </param>
 public RiotApiCaller(suffix _suffix)
 {
     cacheBuild.Add(typeof(T).ToCacheParam());//cache key adding
     Suffix = _suffix;
     if (Suffix == suffix.status)
     {
         Url = string.Format("https://{0}/{1}",
                             Suffix.GetApiType().GetValue(),
                             Suffix.GetApiGroup().ToString2()
                             );
         return;//ended
     }
     else if (Suffix == suffix.CurrentGameInfo)
     {
         Url = string.Format("https://{0}/{1}/{2}",
                             Suffix.GetApiType().GetValue(),
                             Suffix.GetApiGroup().ToString2(),
                             Suffix.GetValue()
                             );
         return;//ended
     }
     else if (_suffix == suffix.featuredGames || _suffix == suffix.championMasteries ||
              _suffix == suffix.championMasteryScore || _suffix == suffix.championMasteryTop || _suffix == suffix.championMastery)
     {
         Url = string.Format("https://{0}/{1}",
                             Suffix.GetApiType().GetValue(),
                             Suffix.GetValue()
                             );
         Url = Url.Replace("api/lol/", "");//BUG: fix it
     }
     else
     {
         Url = string.Format("https://{0}/{{region}}/v{1}/{2}/{3}",
                             Suffix.GetApiType().GetValue(),
                             Suffix.GetApiGroup().GetVersion(),
                             Suffix.GetApiGroup().ToString2(),
                             Suffix.GetValue()
                             );
         Url = Url.Replace("/team/team/", "/team/"); //BUG: fix it (for => suffix.teamByIds)
         Url = Url.Replace("championRotation/", ""); //BUG suffix.championRotation, suffix.championRotation
     }
 }
Пример #4
0
        static int[] buildSuffixArray(byte[] txt)
        {
            int n = txt.Length;

            // A structure to store suffixes and their indexes
            suffix[] suffixes = new suffix[n];
            var      sw       = new Stopwatch();

            sw.Start();
            // Store suffixes and their indexes in an array of structures.
            // The structure is needed to sort the suffixes alphabatically
            // and maintain their old indexes while sorting
            for (int i = 0; i < n; i++)
            {
                suffixes[i].index = i;
                suffixes[i].rank0 = (short)txt[i];
                suffixes[i].rank1 = ((i + 1) < n) ? (short)txt[i + 1] : (short)-1;
            }
            var initSuffixes = sw.ElapsedMilliseconds;

            // Sort the suffixes using the comparison function
            // defined above.
            Array.Sort(suffixes, cmp);

            var firstSort = sw.ElapsedMilliseconds;

            int iter = 0;

            // At this point, all suffixes are sorted according to first
            // 2 characters.  Let us sort suffixes according to first 4
            // characters, then first 8 and so on
            int[] ind = new int[n];  // This array is needed to get the index in suffixes[]
                                     // from original index.  This mapping is needed to get
                                     // next suffix.
            for (int k = 4; k < 2 * n; k = k * 2)
            {
                // Assigning rank and index values to first suffix
                short rank      = 0;
                int   prev_rank = suffixes[0].rank0;
                suffixes[0].rank0      = rank;
                ind[suffixes[0].index] = 0;

                // Assigning rank to suffixes
                for (int i = 1; i < n; i++)
                {
                    // If first rank and next ranks are same as that of previous
                    // suffix in array, assign the same new rank to this suffix
                    if (suffixes[i].rank0 == prev_rank &&
                        suffixes[i].rank1 == suffixes[i - 1].rank1)
                    {
                        prev_rank         = suffixes[i].rank0;
                        suffixes[i].rank0 = rank;
                    }
                    else // Otherwise increment rank and assign
                    {
                        prev_rank         = suffixes[i].rank0;
                        suffixes[i].rank0 = ++rank;
                    }
                    ind[suffixes[i].index] = i;
                }

                // Assign next rank to every suffix
                for (int i = 0; i < n; i++)
                {
                    int nextindex = suffixes[i].index + k / 2;
                    suffixes[i].rank1 = (nextindex < n)
                        ? suffixes[ind[nextindex]].rank0
                        : (short)-1;
                }

                // Sort the suffixes according to first k characters
                Array.Sort(suffixes, cmp);
                ++iter;
            }

            var doneLooping = sw.ElapsedMilliseconds;

            // Store indexes of all sorted suffixes in the suffix array
            int[] suffixArr = new int[n];
            for (int i = 0; i < n; i++)
            {
                suffixArr[i] = suffixes[i].index;
            }

            // Return the suffix array
            Console.WriteLine("Iterations: {0} ({1},{2},{3}) ", iter, initSuffixes, firstSort, doneLooping);
            return(suffixArr);
        }
Пример #5
0
 static int cmp(suffix a, suffix b)
 {
     return((a.rank0 == b.rank0)
                 ? (a.rank1 - b.rank1)
                 : (a.rank0 - b.rank0));
 }
Пример #6
0
 where item.EndsWith(suffix)
 select item);