public Convert ( object value, |
||
value | object | The value produced by the binding source. |
targetType | The type of the binding target property. | |
parameter | object | The converter parameter to use. |
culture | System | The culture to use in the converter. |
return | object |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
#if WP8
if (value == null || string.IsNullOrEmpty(_resolutionSuffix))
{
return value;
}
var iconUrl = value.ToString().TrimStart('/');
if (iconUrl.Length > 0)
{
var resolutionAwareIconUrl = Path.ChangeExtension(iconUrl, _resolutionSuffix + Path.GetExtension(iconUrl));
var resolutionAwareIconUri = new Uri(resolutionAwareIconUrl, UriKind.Relative);
if (CheckIfUriExists)
{
var resouceStreamResult = Application.GetResourceStream(resolutionAwareIconUri);
if (resouceStreamResult != null && resouceStreamResult.Stream != null)
{
resouceStreamResult.Stream.Dispose();
return resolutionAwareIconUri;
}
}
else
{
return resolutionAwareIconUri;
}
}
return value;
#else
return value;
#endif
}
public void ConvertFromUriToResolutionAwareUri(int scaleFactor, string expectedValue) { var converter = new ResolutionAwareUriConverter(scaleFactor); var value = converter.Convert(TestValue, typeof(Uri), null, CultureInfo.CurrentCulture); Assert.IsNotNull(value); Assert.AreEqual(value.ToString(), expectedValue); }