allow querying for different image types (screenshot, logo)

This commit is contained in:
2015-03-27 00:04:39 +01:00
parent 68070e07c9
commit 063ad18f2c
7 changed files with 51 additions and 6 deletions
+4 -2
View File
@@ -1,5 +1,6 @@
using Bender;
using OnePeek.Entities;
using OnePeek.Api.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -37,9 +38,10 @@ namespace OnePeek.Api
}
public Uri GetImageUri(string urn)
public Uri GetImageUri(string urn, StoreScreenshotType screenshotType)
{
return EndpointUris.GetWindowsPhoneImageUri(urn);
string type = screenshotType.GetEnumDisplayName();
return EndpointUris.GetWindowsPhoneImageUri(urn, type);
}
}
}
+3 -3
View File
@@ -8,7 +8,7 @@ namespace OnePeek.Api
{
internal static class EndpointUris
{
public const string WINDOWSPHONE_IMAGE_URI = "http://cdn.marketplaceimages.windowsphone.com/v8/images/{0}?imageType=ws_icon_large";
public const string WINDOWSPHONE_IMAGE_URI = "http://cdn.marketplaceimages.windowsphone.com/v8/images/{0}?imageType={1}";
public const string WINDOWSPHONE_METADATA_URI = "http://marketplaceedgeservice.windowsphone.com/v9/catalog/apps/{0}?os=8.10.14219.0&cc={1}&lang={2}";
@@ -23,9 +23,9 @@ namespace OnePeek.Api
internal static Uri GetWindowsPhoneImageUri(string urn)
internal static Uri GetWindowsPhoneImageUri(string urn, string type)
{
return Uri(WINDOWSPHONE_IMAGE_URI, urn.Replace("urn:uuid:", ""));
return Uri(WINDOWSPHONE_IMAGE_URI, urn.Replace("urn:uuid:", ""), type);
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.Text;
using System.Threading.Tasks;
namespace OnePeek.Api.Extensions
{
internal static class EnumExtensions
{
public static string GetEnumDisplayName(this Enum value)
{
TypeInfo typeInfo = value.GetType().GetTypeInfo();
FieldInfo fieldInfo = typeInfo.GetDeclaredField(value.ToString());
if (fieldInfo == null)
{
return null;
}
DisplayAttribute attribute = (DisplayAttribute)fieldInfo.GetCustomAttribute(typeof(DisplayAttribute), false);
return attribute != null ? attribute.Name : null;
}
}
}
+2 -1
View File
@@ -13,7 +13,7 @@
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
<TargetFrameworkProfile>Profile44</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -43,6 +43,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StoreCulture.cs" />
<Compile Include="StoreCultureTypeEnum.cs" />
<Compile Include="StoreScreenshotTypeEnum.cs" />
<Compile Include="StoreTypeEnum.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace OnePeek.Entities
{
public enum StoreScreenshotType
{
[Display(Name = "ws_icon_large")]
Logo,
[Display(Name = "ws_screenshot_small")]
ScreenshotSmall,
[Display(Name = "ws_screenshot_large")]
ScreenshotLarge
}
}