您的位置:首页 > 编程语言 > C#

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: