/// <summary> /// </summary> /// <param name="name"></param> /// <param name="region"></param> /// <returns>The ID of a Summoner from their name and region.</returns> public async Task <Summoner> FromNameAsync(string name, eRegion region) { string requestPath = string.Format("summoner/by-name/{0}", name); string url = BuildURL(region, requestPath); using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(url)) using (HttpContent content = response.Content) { string contentStr = await content.ReadAsStringAsync(); var result = await JsonConvert.DeserializeObjectAsync <Dictionary <string, SummonerDTO> >(contentStr); SummonerDTO summonerDTO = result.Select(x => x.Value).FirstOrDefault(); if (summonerDTO == null) { return(null); } //todo: cache summoners. Summoner summoner = new Summoner(summonerDTO); summoner.Region = region; return(summoner); } }
public static TTTRegion Get(eRegion _region) { switch (_region) { case eRegion.A1: return(A1); case eRegion.A2: return(A2); case eRegion.A3: return(A3); case eRegion.B1: return(B1); case eRegion.B2: return(B2); case eRegion.B3: return(B3); case eRegion.C1: return(C1); case eRegion.C2: return(C2); case eRegion.C3: return(C3); default: return(A1); } }
protected string BuildURL(eRegion region, string requestPath) { string baseURL = "http://prod.api.pvp.net/api/lol"; // string url = string.Format("http://prod.api.pvp.net/api/lol/{0}/v1.2/summoner/by-name/{1}?api_key={2}", region, name, key); string url = string.Format("{0}/{1}/{2}/{3}?api_key={4}", baseURL, region.ToString(), Version, requestPath, APIConfiguration.APIKey); return url; }
protected string BuildURL(eRegion region, string requestPath) { string baseURL = "http://prod.api.pvp.net/api/lol"; // string url = string.Format("http://prod.api.pvp.net/api/lol/{0}/v1.2/summoner/by-name/{1}?api_key={2}", region, name, key); string url = string.Format("{0}/{1}/{2}/{3}?api_key={4}", baseURL, region.ToString(), Version, requestPath, APIConfiguration.APIKey); return(url); }
List <cSquare> buildRegionLinks(int row, int col) { eRegion thisRegion = GetRegion(row, col); List <cSquare> retList = new List <cSquare>(); int iRow = -1; int iCol = -1; switch (thisRegion) { case eRegion.TopLeft: iRow = iCol = 0; break; case eRegion.TopCenter: iRow = 0; iCol = 3; break; case eRegion.TopRight: iRow = 0; iCol = 6; break; case eRegion.CenterLeft: iRow = 3; iCol = 0; break; case eRegion.Center: iRow = 3; iCol = 3; break; case eRegion.CenterRight: iRow = 3; iCol = 6; break; case eRegion.LowerLeft: iRow = 6; iCol = 0; break; case eRegion.LowerCenter: iRow = 6; iCol = 3; break; case eRegion.LowerRight: iRow = 6; iCol = 6; break; default: throw new Exception("Invalid eRegion in cValidation.buildRegionLinks()"); } retList.AddRange(BuildRegionList(iRow, iCol)); return(retList); }
void addRegionLinks(int row, int col) { eRegion thisRegion = GetRegion(row, col); int iRow = -1; int iCol = -1; switch (thisRegion) { case eRegion.TopLeft: iRow = iCol = 0; break; case eRegion.TopCenter: iRow = 0; iCol = 3; break; case eRegion.TopRight: iRow = 0; iCol = 6; break; case eRegion.CenterLeft: iRow = 3; iCol = 0; break; case eRegion.Center: iRow = 3; iCol = 3; break; case eRegion.CenterRight: iRow = 3; iCol = 6; break; case eRegion.LowerLeft: iRow = 6; iCol = 0; break; case eRegion.LowerCenter: iRow = 6; iCol = 3; break; case eRegion.LowerRight: iRow = 6; iCol = 6; break; default: throw new Exception("Invalid eRegion in cValidation.addRegionLinks()"); } BuildRegionList(iRow, iCol); }
/// <summary> /// </summary> /// <param name="name"></param> /// <param name="region"></param> /// <returns>The ID of a Summoner from their name and region.</returns> public async Task<List<ChampionDTO>> GetAllChampionsAsync(eRegion region) { string requestPath = "champion"; string url = BuildURL(region, requestPath); using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(url)) using (HttpContent content = response.Content) { string contentStr = await content.ReadAsStringAsync(); Console.WriteLine("content: " + contentStr); var result = await JsonConvert.DeserializeObjectAsync<Dictionary<string, List<ChampionDTO>>>(contentStr); List<ChampionDTO> champions = result.Select(x => x.Value).FirstOrDefault(); return champions; } }
/// <summary> /// </summary> /// <param name="name"></param> /// <param name="region"></param> /// <returns>The ID of a Summoner from their name and region.</returns> public async Task <List <ChampionDTO> > GetAllChampionsAsync(eRegion region) { string requestPath = "champion"; string url = BuildURL(region, requestPath); using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(url)) using (HttpContent content = response.Content) { string contentStr = await content.ReadAsStringAsync(); Console.WriteLine("content: " + contentStr); var result = await JsonConvert.DeserializeObjectAsync <Dictionary <string, List <ChampionDTO> > >(contentStr); List <ChampionDTO> champions = result.Select(x => x.Value).FirstOrDefault(); return(champions); } }
/// <summary> /// </summary> /// <param name="name"></param> /// <param name="region"></param> /// <returns>The ID of a Summoner from their name and region.</returns> public async Task<Summoner> FromNameAsync(string name, eRegion region) { string requestPath = string.Format("summoner/by-name/{0}", name); string url = BuildURL(region, requestPath); using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(url)) using (HttpContent content = response.Content) { string contentStr = await content.ReadAsStringAsync(); var result = await JsonConvert.DeserializeObjectAsync<Dictionary<string, SummonerDTO>>(contentStr); SummonerDTO summonerDTO = result.Select(x => x.Value).FirstOrDefault(); if (summonerDTO == null) { return null; } //todo: cache summoners. Summoner summoner = new Summoner(summonerDTO); summoner.Region = region; return summoner; } }
public static extern int shock_Create(out IntPtr psx, eRegion region, void *firmware512k);
public static void Input(eSymbol _symbol, eRegion _region) { Input(_symbol, Get(_region)); }
public static extern int shock_Create(out IntPtr psx, eRegion region, void* firmware512k);
void SelectRegion(eRegion _region) { TicTacToeAI.Input(TicTacToeAI.PlayerSymbol, _region); }
eRegion GetRegion(int row, int col) { eRegion eReturn = eRegion.NotSet; _leftRight = eLeftRight.NotSet; _topBottom = eTopBottom.NotSet; SetLeftRight(col); setTopBottom(row); switch (_leftRight) { case eLeftRight.Left: /////////////////////// // LEFT-RIGHT = LEFT // /////////////////////// switch (_topBottom) { case eTopBottom.Top: eReturn = eRegion.TopLeft; break; case eTopBottom.Center: eReturn = eRegion.CenterLeft; break; case eTopBottom.Bottom: eReturn = eRegion.LowerLeft; break; default: throw new Exception("Invalid eTopBottom value in cValidationLists.GetRegion()"); } break; case eLeftRight.Center: ///////////////////////// // LEFT-RIGHT = CENTER // ///////////////////////// switch (_topBottom) { case eTopBottom.Top: eReturn = eRegion.TopCenter; break; case eTopBottom.Center: eReturn = eRegion.Center; break; case eTopBottom.Bottom: eReturn = eRegion.LowerCenter; break; default: throw new Exception("Invalid eTopBottom value in cValidationLists.GetRegion()"); } break; case eLeftRight.Right: switch (_topBottom) { //////////////////////// // LEFT-RIGHT = RIGHT // //////////////////////// case eTopBottom.Top: eReturn = eRegion.TopRight; break; case eTopBottom.Center: eReturn = eRegion.CenterRight; break; case eTopBottom.Bottom: eReturn = eRegion.LowerRight; break; default: throw new Exception("Invalid eTopBottom value in cValidationLists.GetRegion()"); } break; default: throw new Exception("Invalid LeftRight enum value in cValiationLists.GetRegion()"); } // END SWITCH return(eReturn); }