is possible this wrote simple, code is here:
foreach (var friend in friends)
{
friend.Value.blockQuote = GetBlockQuote(friend.Value.nick);
if (friend.Value.photo == "0")
{
if (friend.Value.sex == 1)
{
var img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri(@"avatars\man.jpg",
UriKind.Relative);
img.EndInit();
friend.Value.profilePhoto = img;
}
if (friend.Value.sex == 2)
{
//da default
var img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri(@"avatars\woman.jpg",
UriKind.Relative);
img.EndInit();
friend.Value.profilePhoto = img;
}
}
else
{
var img = new BitmapImage();
img.BeginInit();
img.UriSource = new Uri(friend.Value.photo.Replace(@"\", "").Replace(@"s_", ""), UriKind.Absolute);
img.EndInit();
friend.Value.profilePhoto = img;
}
}
Break out the uri-setting part
Edit
Note that the if-else-part is now a good candidate for Refactor->Extract method