置顶随笔

[置顶]帮我看看这点破事 EVENT

摘要: //免责声明本人想把自己对asp.net下委托和事件的简单理解,略举了小例,不知道这样的委托事件,是否真的是破事。如果对事件的理解和用法错误望高人斧正,新手小弟莫要效尤,以免误入歧途,走火入魔介绍全局共4个文件:Alarm.cs是个主题类,(好像是观察者模式的一个名称),想象成一个警报中心。它负责向CCTV,BBC等各大机构提供服务SafetyEventArgs主题向观察者发送的信息参数类,包括防...阅读全文

posted @ 2009-05-10 15:22 技术拓荒者 阅读(139) 评论(1) 编辑

[置顶]Protocol Buffers vs xml

    只有注册用户登录后才能阅读该文。阅读全文

posted @ 2008-07-09 16:08 技术拓荒者 阅读(20) 评论(0) 编辑

2009年5月10日

帮我看看这点破事 EVENT

      //免责声明

      本人想把自己对asp.net下委托和事件的简单理解,略举了小例,
      不知道这样的委托事件,是否真的是破事。如果对事件的理解和用法错误望高人斧正,
      新手小弟莫要效尤,以免误入歧途,走火入魔

介绍

全局共4个文件:

      Alarm.cs

            是个主题类,(好像是观察者模式的一个名称),想象成一个警报中心。它负责向CCTV,BBC等各大机构提供服务

      SafetyEventArgs

            主题向观察者发送的信息参数类,包括防火指数,防洪指数

      ChannelCCTV1.aspx

            观察者,向警报中心取得数据,然后告诉各位看客。也就是三个按钮  

       ChannelCCTV1.aspx.cs

             ChannelCCTV1.aspx的逻辑    

全局目录结构

                          

 

1 先看 Alarm.cs

      

 

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Alarm 的摘要说明
/// </summary>
public class Alarm
{
    SafetyEventArgs sea;
    public  delegate void DelegatePreAlarm(object sender, SafetyEventArgs e);
    public event DelegatePreAlarm eventAlarm;
    public void OnEvent()
    {
        System.Random rnd = new Random();
        sea = new SafetyEventArgs();
        sea.FireIndex=rnd.Next(100);
        sea.FloodIndex=rnd.Next(100);
        if (this.eventAlarm != null)
        {
            //第一个参数this将把类class Alarm传出去
            //传递给事件监听的所有方法
            //所有方法有一个标准,就是符合该事件相关的委托
            //目前委托的规范是 输出void  输入object, SafetyEventArgs;
            //符合委托的规范的所有方法都可以交给事件监听,
            //一旦这个方法(触发事件的方法OnEvent)被调用,将发送给所有的观察者
            this.eventAlarm(this, sea);
        }
    }

}

 

 

SafetyEventArgs.cs

 

 

 

 

Title

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// SafetyEventArgs 的摘要说明
/// </summary>
public class SafetyEventArgs
{

    /// <summary>
    /// 防火指数
    /// </summary>
    private int fireIndex;

    /// <summary>
    /// Gets or sets the index of the fire.
    /// </summary>
    /// <value>The index of the fire.</value>
    public int FireIndex
    {
        get { return fireIndex; }
        set { fireIndex = value; }
    }
    /// <summary>
    /// 防洪指数
    /// </summary>
    private int floodIndex;

    /// <summary>
    /// Gets or sets the index of the flood.
    /// </summary>
    /// <value>The index of the flood.</value>
    public int FloodIndex
    {
        get { return floodIndex; }
        set { floodIndex = value; }
    }

    /// <summary>
    /// Initializes a new instance of the <see cref="SafetyEventArgs"/> class.
    /// </summary>
 public SafetyEventArgs()
 {

 }

    /// <summary>
    /// Initializes a new instance of the <see cref="SafetyEventArgs"/> class.
    /// </summary>
    /// <param name="fire">The fire.</param>
    /// <param name="flood">The flood.</param>
 public SafetyEventArgs(int fire,int flood)
 {
        this.fireIndex = fire;
        this.floodIndex = flood;
 }

 

      

 

 

 

 

 

ChannelCCTV1.aspx

 

Title<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChannelCCTV1.aspx.cs" Inherits="ChannelCCTV1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="订阅综合信息" OnClick="Button1_Click" />
        <asp:Button ID="Button2" runat="server" Text="订阅防火信息" OnClick="Button2_Click"  />
        <asp:Button ID="Button3" runat="server" Text="订阅防洪信息" OnClick="Button3_Click" /> 
    </div>
    </form>
</body>
</html>


 

ChannelCCTV1.aspx.cs

 

Title

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ChannelCCTV1 : System.Web.UI.Page
{
    private string name = "CCTV1";

    /// <summary>
    /// 声明主题
    /// </summary>
    private static Alarm alarm;
    /// <summary>
    /// 初始化主题
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        alarm = new Alarm();
    }

    /// <summary>
    /// 这是个符合委托规范的方法
    /// 报道防火信息
    /// Reports the fire.
    /// </summary>
    /// <param name="sender">The sender.</param>
    /// <param name="e">The <see cref="SafetyEventArgs"/> instance containing the event data.</param>
    public void ReportFire(object sender, SafetyEventArgs e)
    {
        string resp = string.Format("<br>sender is:" + sender.ToString() + "<br />" + " info: fire index is:{0}" + "<br />" , e.FireIndex);
        Response.Write(resp);
        Response.Write(" by "+this.name);
    }
    /// <summary>
    /// 这是个符合委托规范的方法
    /// 报道防洪信息
    /// Reports the flood.
    /// </summary>
    /// <param name="sender">The sender.</param>
    /// <param name="e">The <see cref="SafetyEventArgs"/> instance containing the event data.</param>
    public void ReportFlood(object sender, SafetyEventArgs e)
    {
        string resp = string.Format("<br>sender is:" + sender.ToString() + "<br />" + " info: flood index is:{0}",e.FloodIndex);
        Response.Write(resp);
        Response.Write("<br> by "+this.name);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        alarm.eventAlarm += new Alarm.DelegatePreAlarm(this.ReportFire);
        alarm.eventAlarm += new Alarm.DelegatePreAlarm(this.ReportFlood);
        alarm.OnEvent();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        alarm.eventAlarm += new Alarm.DelegatePreAlarm(this.ReportFire);
        alarm.OnEvent();
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        alarm.eventAlarm += new Alarm.DelegatePreAlarm(this.ReportFlood);
        alarm.OnEvent();
    }
}


 

 

 

 

 

 

运行效果

 

 

                               

 

 

订阅综合效果

 

 

 

 

订阅防火信息效果

 

 

over,看大家的笑果

 

 

 

 

 

 

 

posted @ 2009-05-10 15:22 技术拓荒者 阅读(139) 评论(1) 编辑

2009年4月7日

<叶子>的离去

被称为“疗伤歌手”的台湾歌手阿桑,因患乳腺癌于4月6日早上8点半,病逝于台湾新店慈济医院,享年34岁。

    天妒英才。阿桑的突然离去,无疑是华语乐团的一大损失。我们当然舍不得又一位优秀的歌手离我们而去,唯有祝愿阿桑在天堂里唱歌不再寂寞。

来源 中国娱乐网(www.yule.com.cn) 原文:http://news.yule.com.cn/html/200904/41098.html

posted @ 2009-04-07 22:44 技术拓荒者 阅读(23) 评论(0) 编辑

2008年12月31日

离开的心情

送别宴后。拿到工资和小礼品

等待,下班

还有三十分钟

这是很长,不,是很短的时间

长得如此让我前所未有的无所事事,

短的让我总觉得似乎少做了件事情,

努力寻找,在公司留下的零星记忆碎片,

却来不及拾起。

生活中的一扇门关闭,和一扇门的开启

总是让人充满复杂感情的事情

是一趟的火车快到目的站的心情,到达时的激动带着不安,高兴明显夹着点忧伤

想给所有谋面的一个问候,我想他们会觉得很平常,但对我,却是庄严,

安慰自己:轻轻的走,如轻轻的来!

默默地,我已经表达

再见,我的旅途朋友们。祝好!

 

                                            2008 12 31 17 30

                                           

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2008-12-31 17:43 技术拓荒者 阅读(173) 评论(0) 编辑

今天,2008的last day,离职

这几天还不错

android的mapview已经动起来了

aspnet访问db2调试好了

oracle的全文检索demo完成的不错

 

今天早上顺利地买到了3号的火车票

把户口迁移的事情安排妥帖了

今天中午公司有请饭

这个年终,工作了1年半,技术进步不小,广度很大,希望在java的android平台上和。Net平台上继续深入

最后,祝福自己 新年愉快,早日找到理想工作和伴侣

心想事成万事如意

posted @ 2008-12-31 10:46 技术拓荒者 阅读(36) 评论(0) 编辑

2008年12月11日

这个冬天冷啊郁闷哇

money没得,换地方混要重新找工作了,MM要放me鸽子,真是人生不如意事常八九!

 

20081214

昆明,这个早晨,特别的昏暗

老天,宣布:我失恋了

很安静,只听得见,两耳轰鸣

精神恍惚,行尸走肉

还说给我过生日,干什么呀,心都死了,还什么生日

最常去的网吧关门了,绕道了两回,终于到了个网吧,来找到我的迷失灵魂

我最爱的war3,浩方,找不到路径

记得昨天约我去视频,说起要剪短头发,不知所云,经过baidu,乃知女子失恋之举,悲哉

叫她给我首《该死的温柔》,她推了

《爱得太迟》《爱情里没有谁对谁错》

《不要在我寂寞的时候说爱我》,《有一种爱叫做放手》,

《爱你就让你幸福》《不要问爱是什么》《不想看到你流泪》

《我不后悔》

 

网友小猫咪推荐《我们的纪念》《隐形的翅膀》

我想起了阿杜的早期作品天黑系列《天黑》《离别》《andy》

 

posted @ 2008-12-11 11:59 技术拓荒者 阅读(29) 评论(1) 编辑

2008年11月3日

Android好消息 摩托罗拉拟裁员 侧重使用谷歌Android软件

http://tech.163.com/08/1029/09/4PDO4H8A000915BE.html

摩托罗拉拟裁员 侧重使用谷歌Android软件

2008-10-29 09:33:41 来源: 网易科技报道 网友评论 9 进入论坛
  •   该计划细节或将于周四摩托罗拉财报出炉当日公布。裁员规模可能达数千人。

网易科技讯 据路透社10月28日援引《华尔街日报》文章报道,由于金融危机给全球手机业的经营带来了巨大影响,摩托罗拉集团联合首席执行官Sanjay Jha决定进一步裁减公司员工,另外,摩托罗拉手机操作系统也将发生重大的变更。

根据《华尔街日报》的文章,摩托罗拉公司将在本周四正式公布此次的裁员计划,其规模很可能达到数千人,另外,目前主要负责公司手机产品业务的Jha表示,公司的部分手机产品将采用谷歌公司研发的Android操作系统。该文章透露,Android操作系统将广泛使用于摩托罗拉的中端手机产品,而这个价位的手机是摩托罗拉公司目前最为重要的利润来源,另外,公司的商务机产品将使用由微软公司所研发的操作系统。

而对于低端产品,摩托罗拉公司将使用自主研发的P2K操作系统。另外,该文章还表示,摩托罗拉公司正在寻求合适的代工生产商,从而将部分手机产品的生产过程外包。

posted @ 2008-11-03 13:53 技术拓荒者 阅读(37) 评论(0) 编辑

2008年10月23日

不负众望 Google Android 平台正式开源

摘要: Google Android 平台正式开源2008-10-22 来自:”专家项目实Google 推出移动设备软件平台 Android 之时,曾向开发者开放 SDK 包,并许诺将在开源许可模式下开放其全部代码,今天,Google 与其合作伙伴,在 Open Handset Alliance 兑现了其承诺,用户现在可以正式下载 Android 平台的源代码。源代码基于 Apache 2.0...阅读全文

posted @ 2008-10-23 17:37 技术拓荒者 阅读(35) 评论(0) 编辑

2008年9月28日

XML Schema数据类型详解

摘要: 转自下列网址http://hi.baidu.com/qualylee/blog/item/5f072ff5674e2d21bc310987.htmlXML学习笔记二--XML Schema数据类型详解2008-03-06 21:06 XML Schema中的数据类型可分为简单类型和复合类型,其中简单类型是不能分割的原子信息;复合类型类似于编程语言中的自定义类型,它是由已存在的简单类型组合而成。 X...阅读全文

posted @ 2008-09-28 11:17 技术拓荒者 阅读(875) 评论(0) 编辑

2008年9月24日

正式版1.0发布Android

摘要: http://code.google.com/android/ Getting Started Learn about Android Download the SDK Join the community. Participate in our discussion group through email or the web. 下载1.0SDK http://code.google.com/a...阅读全文

posted @ 2008-09-24 12:40 技术拓荒者 阅读(163) 评论(0) 编辑

2008年8月19日

google android 新SDK终于发布(the Android 0.9 SDK beta)

摘要: http://code.google.com/android/intro/upgrading.htmlUpgrading the SDKThis guide will help you migrate your development environment and applications to the Android 0.9 SDK beta. Use this guide if you've...阅读全文

posted @ 2008-08-19 15:48 技术拓荒者 阅读(300) 评论(1) 编辑

导航

<2012年2月>
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910

公告

昵称:技术拓荒者
园龄:3年7个月
粉丝:1
关注:1

搜索

 
 

常用链接

我的标签

随笔档案

最新评论

阅读排行榜

评论排行榜

推荐排行榜