VB9和Atom

<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog01.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>

原文:VB9 and Atom


VB9和Atom

我最近在试图说明C#所具有的高素养语言特点时,我的一大帮朋友都给我发来悲哀的信息。

为了吸引我们中所有的软件蓝领,我想我应该用一小段VB9程序来清洗调色板,演示Erik & Co. 放在语言中对Xml的支持功能。

这个程序是一个Console,提供一个Atom服务,这个服务包含了有关运行主机进程的数据。

如果你运行的是Xp,那么一定要改变端口号或者停止IIS5,因为这个程序要使用HTTP.SYS而IIS5却不(IIS6或更高版本使用HTTP.SYS,因此每个人都可以打80端口的注意。)

欣赏这段代码吧!

Imports System
Imports System.Net
Imports System.Diagnostics

Module Module1

Sub Main()
' start listening on /bob/
Dim listener = New HttpListener()
listener.Prefixes.Add("http://+:80/bob/")
listener.Start()

' pump requests
Dim done = False
While Not done
Dim context = listener.GetContext()
If (context Is Nothing) Then
done = True
Else
context.Response.ContentType = "application/atom+xml"
Dim data = _
<feed xmlns="&lt;a href=" http:>http://www.w3.org/2005/Atom"&gt;<br><title>My Processes</title> <br><link href="&lt;a%20href=" http:>http://localhost/bob/"/&gt;<br><updated></updated><br><author><br><name>Don Box</name><br></author><br><id>urn:uuid:</id><br><br> Where proc.WorkingSet64 &gt; 10000 _<br> Select _<br><entry xmlns="&lt;a href=" http:>http://www.w3.org/2005/Atom"&gt;<br><title></title> <br><id>urn:uuid:</id><br><updated></updated><br><summary></summary><br></entry> _<br> %&gt;<br></feed>

Dim writer = XmlWriter.Create(context.Response.OutputStream)
Data.WriteTo(writer)
writer.Close()
context.Response.Close()
End If
End While
End Sub
End Module



Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=1428842


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值