C#组件开发
2007-05-14 16:20
357 查看
微软即将发布的 Visual Studio .NET 将使程序开发人员获得一个集
成开发环境,它不但为开发传统的 C/C++ 应用程序,而且也为令人振奋
的 Microsoft .NET 组件提供了丰富的工具。这些以管理代码编写、在通
用语言运行时构建的组件向开发人员提供了一个全新的混合开发环境,即
象 Microsoft Visual Basic 一样容易,而同时又提供了强大的低级编程
能力,与 ATL 或 MFC 更加相关。随着以生产效率为中心的管理环境的到
来,它可与传统 COM 组件很好地协同工作。开发人员可以将更多时间花
在构建大型组件上,而不用再为内存泄漏、安全和头文件担心。
Microsoft .NET FrameworkVisual Studio
.NET (VS .NET) VS .NET
VS .NET
VS.NET
.NET Framework
Microsoft . NET Framework
Visual Studio . NET System.
ComponentModel.IComponentIComponent
IComponent
.NET
using System;
using System.ComponentModel;
public class BoolTracker : Component {
private bool state;
private EventHandler handler;
private static object EventValueChanged = new object();
public BoolTracker() {
}
public bool Value {
get {
return state;
}
set {
if (this.state != value) {
this.state = value;
OnValueChanged(new EventArgs());
}
}
}
public void AddOnValueChanged(EventHandler h) {
handler= (EventHandler)Delegate.Combine(handler, h);
}
protected virtual void OnValueChanged(EventArgs e) {
if (handler != null) {
handler(this, e);
}
}
public void RemoveOnValueChanged(EventHandler h) {
handler = (EventHandler)Delegate.Remove(handler, h);
}
}
Visual Studio.NET
Win
“Value”TrueFalse
True False OnValueChanged
Value
/“Value”“”
Visual Studio .NET
VS .NET
System.ComponentModel.Member Attribute
Value
System.Component
Model.BrowsableAttribute
[Browsable(false)]
public bool Value {
get {
return state;
}
set {
if (this.state != value) {
this.state = value;
OnValueChanged(new EventArgs());
}
}
}
“BrowsableAttribute”“Browsable”
C# “Attribute”
BrowsableAttribute “Browsable”
“browsable”
BrowsableAttribute
Microsoft .NET Framework
BrowsableAttribute
BindableAttribute
CategoryAttribute(“Appearance”,
“Layout”, “Behavior”,“ Misc”
DefaultEventAttribute/ DefaultPropertyAttribute
HelpAttribute
LicenseProviderAttribute License
Provider
MergablePropertyAttribute
PersistableAttribute Win Forms Designer Component
Designer
PersistContentsAttribute
ICollection
ShowInToolboxAttribute
ToolBoxItemAttriubte ToolboxItem
成开发环境,它不但为开发传统的 C/C++ 应用程序,而且也为令人振奋
的 Microsoft .NET 组件提供了丰富的工具。这些以管理代码编写、在通
用语言运行时构建的组件向开发人员提供了一个全新的混合开发环境,即
象 Microsoft Visual Basic 一样容易,而同时又提供了强大的低级编程
能力,与 ATL 或 MFC 更加相关。随着以生产效率为中心的管理环境的到
来,它可与传统 COM 组件很好地协同工作。开发人员可以将更多时间花
在构建大型组件上,而不用再为内存泄漏、安全和头文件担心。
Microsoft .NET FrameworkVisual Studio
.NET (VS .NET) VS .NET
VS .NET
VS.NET
.NET Framework
Microsoft . NET Framework
Visual Studio . NET System.
ComponentModel.IComponentIComponent
IComponent
.NET
using System;
using System.ComponentModel;
public class BoolTracker : Component {
private bool state;
private EventHandler handler;
private static object EventValueChanged = new object();
public BoolTracker() {
}
public bool Value {
get {
return state;
}
set {
if (this.state != value) {
this.state = value;
OnValueChanged(new EventArgs());
}
}
}
public void AddOnValueChanged(EventHandler h) {
handler= (EventHandler)Delegate.Combine(handler, h);
}
protected virtual void OnValueChanged(EventArgs e) {
if (handler != null) {
handler(this, e);
}
}
public void RemoveOnValueChanged(EventHandler h) {
handler = (EventHandler)Delegate.Remove(handler, h);
}
}
Visual Studio.NET
Win
“Value”TrueFalse
True False OnValueChanged
Value
/“Value”“”
Visual Studio .NET
VS .NET
System.ComponentModel.Member Attribute
Value
System.Component
Model.BrowsableAttribute
[Browsable(false)]
public bool Value {
get {
return state;
}
set {
if (this.state != value) {
this.state = value;
OnValueChanged(new EventArgs());
}
}
}
“BrowsableAttribute”“Browsable”
C# “Attribute”
BrowsableAttribute “Browsable”
“browsable”
BrowsableAttribute
Microsoft .NET Framework
BrowsableAttribute
BindableAttribute
CategoryAttribute(“Appearance”,
“Layout”, “Behavior”,“ Misc”
DefaultEventAttribute/ DefaultPropertyAttribute
HelpAttribute
LicenseProviderAttribute License
Provider
MergablePropertyAttribute
PersistableAttribute Win Forms Designer Component
Designer
PersistContentsAttribute
ICollection
ShowInToolboxAttribute
ToolBoxItemAttriubte ToolboxItem
相关文章推荐
- Transform组件C#游戏开发快速入门
- C#之二十一 创建MDI应用程序和组件开发
- 第8章 C# .NET 开源可进行二次开发的即时通讯组件提供全部源码下载
- asp.net(c#)开发中的文件上传组件uploadify的使用方法(带进度条)
- C#使用Xamarin开发可移植移动应用终章(11.获取设备信息与常用组件,开源一个可开发模版.)
- c#组件开发
- 第8章 C# .NET 开源可进行二次开发的即时通讯组件提供全部源码下载
- C#组件开发——简单计数器
- asp.net(c#)开发中的文件上传组件uploadify的使用方法(带进度条)
- C#开发系统服务时用的定时器组件
- C#之二十一 创建MDI应用程序和组件开发
- 使用C#开发COM+组件
- 第8章 C# .NET 开源可进行二次开发的即时通讯组件提供全部源码下载
- 关于C#开发OCX组件的说明
- [转]详解C#组件开发的来龙去脉
- asp.net(c#)开发中的文件上传组件uploadify的使用方法(带进度条)
- ASP.NET,C#.NET 通用权限系统组件源码使用说明,程序开发的尚方宝剑,程序架构标准参考,程序开发必备知识
- C#组件开发必须了解
- Transform组件C#游戏开发快速入门
- C#组件开发 -- 索引器