本文整理汇总了C#中Region.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Region.ToString方法的具体用法?C# Region.ToString怎么用?C# Region.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Region
的用法示例。
在下文中一共展示了Region.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildReferenceDto
private object BuildReferenceDto(Region item)
{
return new{
StringId = _stringConverter.ToString(item),
Description = item.ToString(),
};
}
示例2: RequestByName
/// <summary>
/// Search the data from the summoner
/// </summary>
/// <param name="name">Summoner Name</param>
/// <returns>Summoner Object</returns>
public bool RequestByName(string name, Region region)
{
Rootobject root = null;
// URL Request
string apiKey = "fbfa3c47-9c26-4891-8e55-c50a4f3ad3ba";
string uri = "https://na.api.pvp.net/api/lol/" + region.ToString() + "/v1.4/summoner/by-name/";
string adds = name + "?api_key=" + apiKey;
// Get JSON response from server
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(uri);
var response = client.GetAsync(adds).Result;
// Convert to object
var responseJson = response.Content.ReadAsStringAsync().Result;
root = JsonConvert.DeserializeObject<Rootobject>(responseJson);
info.name = root.summoner.name;
return (true);
/*
if (root.summoner.id != 0)
{
this.id = root.summoner.id;
this.name = root.summoner.name;
this.summonerLevel = root.summoner.summonerLevel;
this.profileIconId = root.summoner.profileIconId;
this.revisionDate = root.summoner.revisionDate;
return (true);
}
else {
this.name = uri + adds;
return (false);
}*/
}
示例3: GetSummonerAsync
/// <summary>
/// Get a summoner by id asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="summonerId">Id of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
public async Task<Summoner> GetSummonerAsync(Region region, int summonerId)
{
var json = await requester.CreateRequestAsync(string.Format(SummonerRootUrl, region.ToString())
+ string.Format(IdUrl, summonerId));
var obj = (await JsonConvert.DeserializeObjectAsync<Dictionary<long, Summoner>>(json)).Values.FirstOrDefault();
obj.Region = region;
return obj;
}
示例4: GetSummoner
/// <summary>
/// Get a summoner by id synchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a summoner.</param>
/// <param name="summonerId">Id of the summoner you're looking for.</param>
/// <returns>A summoner.</returns>
public Summoner GetSummoner(Region region, int summonerId)
{
var json = requester.CreateRequest(string.Format(SummonerRootUrl, region.ToString())
+ string.Format(IdUrl, summonerId));
var obj = JsonConvert.DeserializeObject<Dictionary<long, Summoner>>(json).Values.FirstOrDefault();
obj.Region = region;
return obj;
}
示例5: CreateProvider
/// <summary>
/// Creates a tournament provider and returns its ID.
/// </summary>
/// <param name="region">The region in which the provider will be running tournaments.</param>
/// <param name="url">
/// The provider's callback URL to which tournament game results in this region should be posted. The URL
/// must be well-formed, use the http or https protocol, and use the default port for the protocol (http URLs must use
/// port 80, https URLs must use port 443).
/// </param>
/// <returns>The ID of the provider.</returns>
public TournamentProvider CreateProvider(Region region, string url)
{
var body = new Dictionary<string, object> { { "url", url }, { "region", region.ToString().ToUpper() } };
var json = requester.CreatePostRequest(TournamentRootUrl + CreateProviderUrl, Region.global,
JsonConvert.SerializeObject(body));
// json is an int directly
var provider = new TournamentProvider { Id = int.Parse(json) };
return provider;
}
示例6: GetChampions
/// <summary>
/// Get a list of all champions synchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="championData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>A ChampionListStatic object containing all champions.</returns>
public ChampionListStatic GetChampions(Region region, ChampionData championData = ChampionData.none
, Language language = Language.en_US)
{
var wrapper = Cache.Get<ChampionListStaticWrapper>(ChampionsCacheKey);
if (wrapper == null || language != wrapper.Language || championData != wrapper.ChampionData)
{
var json = requester.CreateRequest(string.Format(ChampionRootUrl, region.ToString())
, new List<string>() { string.Format("locale={0}", language.ToString())
, championData == ChampionData.none ? string.Empty
: string.Format("champData={0}", championData.ToString()) });
var champs = JsonConvert.DeserializeObject<ChampionListStatic>(json);
wrapper = new ChampionListStaticWrapper(champs, language, championData);
Cache.Add<ChampionListStaticWrapper>(ChampionsCacheKey, wrapper);
}
return wrapper.ChampionListStatic;
}
示例7: CreateRequest
public override string CreateRequest(string relativeUrl, Region region, List<string> addedArguments = null)
{
RootDomain = region.ToString() + ".api.pvp.net";
HttpWebRequest request = PrepareRequest(relativeUrl, addedArguments);
semaphore.Wait();
{
if (firstRequestInLastTenM == DateTime.MinValue)
{
firstRequestInLastTenM = DateTime.Now;
}
numberOfRequestInLastTenM++;
if (firstRequestInLastTenS == DateTime.MinValue)
{
firstRequestInLastTenS = DateTime.Now;
}
numberOfRequestsInLastTenS++;
if (!IsProdApi && numberOfRequestInLastTenM > MAX_REQUEST_PER_10M)
{
while ((DateTime.Now - firstRequestInLastTenM).TotalSeconds <= 601) ;
numberOfRequestInLastTenM = 1;
firstRequestInLastTenM = DateTime.Now;
}
if (!IsProdApi && numberOfRequestsInLastTenS > MAX_REQUEST_PER_10S)
{
while ((DateTime.Now - firstRequestInLastTenS).TotalSeconds <= 11) ;
numberOfRequestsInLastTenS = 1;
firstRequestInLastTenS = DateTime.Now;
}
if (!IsProdApi && ((DateTime.Now - firstRequestInLastTenS).TotalSeconds > 10))
{
firstRequestInLastTenS = DateTime.Now;
numberOfRequestsInLastTenS = 1;
}
if (!IsProdApi && ((DateTime.Now - firstRequestInLastTenM).TotalMinutes > 10))
{
firstRequestInLastTenM = DateTime.Now;
numberOfRequestInLastTenM = 1;
}
}
semaphore.Release();
return GetResponse(request);
}
示例8: GetRuneNameFor
public static string GetRuneNameFor( Region region )
{
while ( region != null )
{
BaseRegion br = region as BaseRegion;
if ( br != null && br.m_RuneName != null )
return br.m_RuneName;
if (br == null)
return "an unknown location";
if (region.Parent != null)
return region.Parent.ToString();
else
return region.ToString();
}
return null;
}
示例9: GetMasteryAsync
/// <summary>
/// Get a mastery asynchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="masteryId">Id of the mastery to retrieve.</param>
/// <param name="masteryData">Data to retrieve.</param>
/// <param name="language">Language of th data to be retrieved.</param>
/// <returns>A mastery.</returns>
public async Task<MasteryStatic> GetMasteryAsync(Region region, int masteryId
, MasteryData masteryData = MasteryData.none, Language language = Language.en_US)
{
var wrapper = Cache.Get<MasteryStaticWrapper>(MasteryCacheKey + masteryId);
if (wrapper != null && wrapper.Language == language && wrapper.MasteryData == masteryData)
{
return wrapper.MasteryStatic;
}
else
{
var listWrapper = Cache.Get<MasteryListStaticWrapper>(MasteriesCacheKey);
if (listWrapper != null && listWrapper.Language == language && listWrapper.MasteryData == masteryData)
{
if (listWrapper.MasteryListStatic.Masteries.ContainsKey(masteryId))
{
return listWrapper.MasteryListStatic.Masteries[masteryId];
}
else
{
return null;
}
}
else
{
var json = await requester.CreateRequestAsync(string.Format(MasteryRootUrl, region.ToString())
+ string.Format(IdUrl, masteryId.ToString())
, new List<string>() { string.Format("locale={0}", language.ToString())
, masteryData == MasteryData.none ? string.Empty
: string.Format("masteryData={0}", masteryData.ToString()) });
var mastery = await JsonConvert.DeserializeObjectAsync<MasteryStatic>(json);
Cache.Add<MasteryStaticWrapper>(MasteryCacheKey + masteryId
, new MasteryStaticWrapper(mastery, language, masteryData));
return mastery;
}
}
}
示例10: GetItemAsync
/// <summary>
/// Get an item asynchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="itemId">Id of the item to retrieve.</param>
/// <param name="itemData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>An item.</returns>
public async Task<ItemStatic> GetItemAsync(Region region, int itemId, ItemData itemData = ItemData.none
, Language language = Language.en_US)
{
var wrapper = Cache.Get<ItemStaticWrapper>(ItemCacheKey + itemId);
if (wrapper != null && wrapper.Language == language && wrapper.ItemData == itemData)
{
return wrapper.ItemStatic;
}
else
{
var listWrapper = Cache.Get<ItemListStaticWrapper>(ItemsCacheKey);
if (listWrapper != null && listWrapper.Language == language && listWrapper.ItemData == itemData)
{
if (listWrapper.ItemListStatic.Items.ContainsKey(itemId))
{
return listWrapper.ItemListStatic.Items[itemId];
}
else
{
return null;
}
}
else
{
var json = await requester.CreateRequestAsync(string.Format(ItemRootUrl, region.ToString())
+ string.Format(IdUrl, itemId)
, new List<string>() { string.Format("locale={0}", language.ToString())
, itemData == ItemData.none ? string.Empty
: string.Format("itemData={0}", itemData.ToString()) });
var item = await JsonConvert.DeserializeObjectAsync<ItemStatic>(json);
Cache.Add<ItemStaticWrapper>(ItemCacheKey + itemId, new ItemStaticWrapper(item, language, itemData));
return item;
}
}
}
示例11: GetMasteriesAsync
/// <summary>
/// Get a list of all masteries asynchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="masteryData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>An MasteryListStatic object containing all masteries.</returns>
public async Task<MasteryListStatic> GetMasteriesAsync(Region region
, MasteryData masteryData = MasteryData.none, Language language = Language.en_US)
{
var wrapper = Cache.Get<MasteryListStaticWrapper>(MasteriesCacheKey);
if (wrapper == null || language != wrapper.Language || masteryData != wrapper.MasteryData)
{
var json = await requester.CreateRequestAsync(string.Format(MasteryRootUrl, region.ToString())
, new List<string>() { string.Format("locale={0}", language.ToString())
, masteryData == MasteryData.none ? string.Empty
: string.Format("masteryListData={0}", masteryData.ToString()) });
var masteries = await JsonConvert.DeserializeObjectAsync<MasteryListStatic>(json);
wrapper = new MasteryListStaticWrapper(masteries, language, masteryData);
Cache.Add<MasteryListStaticWrapper>(MasteriesCacheKey, wrapper);
}
return wrapper.MasteryListStatic;
}
示例12: GetChallengerLeagueAsync
/// <summary>
/// Get the challenger league for a particular queue asynchronously.
/// </summary>
/// <param name="region">Region in which you wish to look for a challenger league.</param>
/// <param name="queue">Queue in which you wish to look for a challenger league.</param>
/// <returns>A league which contains all the challengers for this specific region and queue.</returns>
public async Task<League> GetChallengerLeagueAsync(Region region, Queue queue)
{
var json = await requester.CreateRequestAsync(
string.Format(LeagueRootUrl, region.ToString()) + LeagueChallengerUrl,
region,
new List<string> { string.Format("type={0}", queue.ToCustomString()) });
return await Task.Factory.StartNew(() => JsonConvert.DeserializeObject<League>(json));
}
示例13: GetItemsAsync
/// <summary>
/// Get a list of all items synchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="itemData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>An ItemListStatic object containing all items.</returns>
public async Task<ItemListStatic> GetItemsAsync(Region region, ItemData itemData = ItemData.none
, Language language = Language.en_US)
{
var wrapper = Cache.Get<ItemListStaticWrapper>(ItemsCacheKey);
if (wrapper == null || language != wrapper.Language || itemData != wrapper.ItemData)
{
var json = await requester.CreateRequestAsync(string.Format(ItemRootUrl, region.ToString())
, new List<string>() { string.Format("locale={0}", language.ToString())
, itemData == ItemData.none ? string.Empty
: string.Format("itemListData={0}", itemData.ToString()) });
var items = await JsonConvert.DeserializeObjectAsync<ItemListStatic>(json);
wrapper = new ItemListStaticWrapper(items, language, itemData);
Cache.Add<ItemListStaticWrapper>(ItemsCacheKey, wrapper);
}
return wrapper.ItemListStatic;
}
示例14: GetSummonerSpellsAsync
/// <summary>
/// Get a list of all summoner spells asynchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="summonerSpellData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>A SummonerSpellListStatic object containing all summoner spells.</returns>
public async Task<SummonerSpellListStatic> GetSummonerSpellsAsync(Region region
, SummonerSpellData summonerSpellData = SummonerSpellData.none, Language language = Language.en_US)
{
var wrapper = Cache.Get<SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey);
if (wrapper == null || wrapper.Language != language || wrapper.SummonerSpellData != summonerSpellData)
{
var json = await requester.CreateRequestAsync(string.Format(SummonerSpellRootUrl, region.ToString())
, new List<string>() { string.Format("locale={0}", language.ToString())
, summonerSpellData == SummonerSpellData.none ? string.Empty
: string.Format("spellData={0}", summonerSpellData.ToString()) });
var spells = await JsonConvert.DeserializeObjectAsync<SummonerSpellListStatic>(json);
wrapper = new SummonerSpellListStaticWrapper(spells, language, summonerSpellData);
Cache.Add<SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey, wrapper);
}
return wrapper.SummonerSpellListStatic;
}
示例15: GetSummonerSpellAsync
/// <summary>
/// Get a summoner spell asynchronously.
/// </summary>
/// <param name="region">Region from which to retrieve the data.</param>
/// <param name="summonerSpell">Summoner spell to retrieve.</param>
/// <param name="summonerSpellData">Data to retrieve.</param>
/// <param name="language">Language of the data to be retrieved.</param>
/// <returns>A summoner spell.</returns>
public async Task<SummonerSpellStatic> GetSummonerSpellAsync(Region region, SummonerSpell summonerSpell
, SummonerSpellData summonerSpellData = SummonerSpellData.none, Language language = Language.en_US)
{
var wrapper = Cache.Get<SummonerSpellStaticWrapper>(SummonerSpellCacheKey + summonerSpell.ToCustomString());
if (wrapper != null && wrapper.SummonerSpellData == summonerSpellData && wrapper.Language == language)
{
return wrapper.SummonerSpellStatic;
}
else
{
var listWrapper = Cache.Get<SummonerSpellListStaticWrapper>(SummonerSpellsCacheKey);
if (listWrapper != null && listWrapper.SummonerSpellData == summonerSpellData
&& listWrapper.Language == language)
{
if (listWrapper.SummonerSpellListStatic.SummonerSpells.ContainsKey(summonerSpell.ToCustomString()))
{
return listWrapper.SummonerSpellListStatic.SummonerSpells[summonerSpell.ToCustomString()];
}
else
{
return null;
}
}
else
{
var json = await requester.CreateRequestAsync(string.Format(SummonerSpellRootUrl, region.ToString())
+ string.Format(IdUrl, (int)summonerSpell)
, new List<string>() { string.Format("locale={0}", language.ToString())
, summonerSpellData == SummonerSpellData.none ? string.Empty
: string.Format("spellData={0}", summonerSpellData.ToString()) });
var spell = await JsonConvert.DeserializeObjectAsync<SummonerSpellStatic>(json);
Cache.Add<SummonerSpellStaticWrapper>(SummonerSpellCacheKey + summonerSpell.ToCustomString()
, new SummonerSpellStaticWrapper(spell, language, summonerSpellData));
return spell;
}
}
}