本文整理汇总了C#中ItemData.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ItemData.ToString方法的具体用法?C# ItemData.ToString怎么用?C# ItemData.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemData
的用法示例。
在下文中一共展示了ItemData.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
}
示例2: 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;
}
示例3: 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<string, ItemListStaticWrapper>(ItemsCacheKey);
if (wrapper != null && language == wrapper.Language && itemData == wrapper.ItemData)
{
return wrapper.ItemListStatic;
}
var json = await requester.CreateGetRequestAsync(
string.Format(ItemRootUrl, region.ToString()),
RootDomain,
new List<string>
{
string.Format("locale={0}", language.ToString()),
itemData == ItemData.none ?
string.Empty :
string.Format("itemListData={0}", itemData.ToString())
});
var items = await Task.Factory.StartNew(() =>
JsonConvert.DeserializeObject<ItemListStatic>(json));
wrapper = new ItemListStaticWrapper(items, language, itemData);
cache.Add(ItemsCacheKey, wrapper, DefaultSlidingExpiry);
return wrapper.ItemListStatic;
}
示例4: 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<string, ItemStaticWrapper>(ItemCacheKey + itemId);
if (wrapper != null && wrapper.Language == language && wrapper.ItemData == itemData)
{
return wrapper.ItemStatic;
}
var listWrapper = cache.Get<String, ItemListStaticWrapper>(ItemsCacheKey);
if (listWrapper != null && listWrapper.Language == language && listWrapper.ItemData == itemData)
{
return listWrapper.ItemListStatic.Items.ContainsKey(itemId) ?
listWrapper.ItemListStatic.Items[itemId] : null;
}
var json = await requester.CreateGetRequestAsync(
string.Format(ItemRootUrl, region.ToString()) + string.Format(IdUrl, itemId),
RootDomain,
new List<string>
{
string.Format("locale={0}", language.ToString()),
itemData == ItemData.none ?
string.Empty :
string.Format("itemData={0}", itemData.ToString())
});
var item = await Task.Factory.StartNew(() =>
JsonConvert.DeserializeObject<ItemStatic>(json));
cache.Add(ItemCacheKey + itemId, new ItemStaticWrapper(item, language, itemData), DefaultSlidingExpiry);
return item;
}
示例5: GetItems
/// <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 ItemListStatic GetItems(Region region, ItemData itemData = ItemData.none,
Language language = Language.en_US)
{
var wrapper = cache.Get<string, ItemListStaticWrapper>(ItemsCacheKey);
if (wrapper == null || language != wrapper.Language || itemData != wrapper.ItemData)
{
var json = requester.CreateGetRequest(
string.Format(ItemRootUrl, region.ToString()),
RootDomain,
new List<string>
{
string.Format("locale={0}", language.ToString()),
itemData == ItemData.none ?
string.Empty :
string.Format("itemListData={0}", itemData.ToString())
});
var items = JsonConvert.DeserializeObject<ItemListStatic>(json);
wrapper = new ItemListStaticWrapper(items, language, itemData);
cache.Add(ItemsCacheKey, wrapper, DefaultSlidingExpiry);
}
return wrapper.ItemListStatic;
}