可以看到返回的结果是一个标准的、且不复杂的XML文档。对于该XML的处理有很多种方法,可以使用Silverlight 2中操作XML的API或者使用LINQ to XML。现在定义一个业务类来对应XML返回的结果,因为我们最终需要的是图片的URL值,如下面的示例代码所示:
C# public class FlickrPhoto { public String Id { get; set; } public String Owner { get; set; } public String Secret { get; set; } public String Server { get; set; } public String Farm { get; set; } public String Title { get; set; }
public String ImageUrl { get { return String.Format ("http://farm{0}.static.flickr.com/{1}/{2}_{3}.jpg", Farm, Server, Id, Secret); } } }
该FlickrPhoto 类的ImageUrl属性通过其他几个属性组合而成,大家可以参考Flickr API的有关文档。现在重新修改OnFlickrDownloadStringCompleted事件,并添加两个全局变量Photos和ImageNumber,使用LINQ to XML实现XML结果与定义的业务类之间的映射,如下面的示例代码所示:
Photos = from photo in xmlPhotos.Element("rsp"). Element("photos").Descendants().ToList() select new FlickrPhoto { Id = (String)photo.Attribute("id"), Owner = (String)photo.Attribute("owner"), Secret = (String)photo.Attribute("secret"), Server = (String)photo.Attribute("server"), Farm = (String)photo.Attribute("farm"), Title = (String)photo.Attribute("title"), };
FlickrPhoto p = Photos.Skip(ImageNumber).First(); BitmapImage bitmap = new BitmapImage(); bitmap.UriSource = new Uri(p.ImageUrl); this.imgTarget.SetValue(Image.SourceProperty, bitmap); } }
C# void imgTarget_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (Photos == null) return; if (ImageNumber >= Photos.Count()) ImageNumber = 0;
FlickrPhoto p = Photos.Skip(ImageNumber).First(); BitmapImage bitmap = new BitmapImage(); bitmap.UriSource = new Uri(p.ImageUrl); this.imgTarget.SetValue(Image.SourceProperty, bitmap);
public class PC {
/**
* 题目:生产者-消费者。
* 同步访问一个数组Integer[10],生产者不断地往数组放入整数1000,数组满时等待;消费者不断地将数组里面的数置零,数组空时等待。
*/
private static final Integer[] val=new Integer[10];
private static
在oracle连接(join)中使用using关键字
34. View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables.
Evaluate the following SQL statement:
SELECT oi.order_id, product_id, order_date
FRO
If i select like this:
SELECT id FROM users WHERE id IN(3,4,8,1);
This by default will select users in this order
1,3,4,8,
I would like to select them in the same order that i put IN() values so:
$(document).ready(
function() {
var flag = true;
$('#changeform').submit(function() {
var projectScValNull = true;
var s ="";
var parent_id = $("#parent_id").v
Mac 在国外很受欢迎,尤其是在 设计/web开发/IT 人员圈子里。普通用户喜欢 Mac 可以理解,毕竟 Mac 设计美观,简单好用,没有病毒。那么为什么专业人士也对 Mac 情有独钟呢?从个人使用经验来看我想有下面几个原因:
1、Mac OS X 是基于 Unix 的
这一点太重要了,尤其是对开发人员,至少对于我来说很重要,这意味着Unix 下一堆好用的工具都可以随手捡到。如果你是个 wi