Inherit from the Business Class Library's Class(从业务类库中的类继承)
2011-11-21 17:24
302 查看
本节知识:
继承业务类库中的类。在类库中有个Person类,我们让我们Contact继承自它这个Person类,使其拥有一些而外的功能。
实现过程:
一般情况下, 业务类(Business Class) 放到一个单独的模块项目中,因为,一个业务类会在Winform项目中用到,也会在Web应用程序中用到,这样两个项目都可以调用这个模块。
1.先新建一个解决方案,取名MySolution,和上一节讲的一样。
然后右键“MySolution.Module”项目|添加|新建项-》选择Domain Object,取名Contact, (我这里是装了两个版本的)
我们看下生成的代码,打开Contac.cs类,这个类是继承自BaseObject 类的。
2.我们改为如下代码:
[/code]
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
这里有几个注意的地方:1应用了[DefaultClassOption]特性。2继承自Person类。3. set访问器 用了SetPropertyValue方法。
defaultclassOption特性有三个方面的作用:业务类被自动生成报表;业务类被加到导航栏中,并且生成ListView视图;能在工具栏生成“新建”按钮
person类也是BaseObject类的子类,也就是说我们的Contact类也是BaseObject的子类,只是间接继承。
SetProperyValue 用于持久化属性;(这是xpo的知识,xpo是xaf的ORM)
3.run ,ok,界面如下:
继承业务类库中的类。在类库中有个Person类,我们让我们Contact继承自它这个Person类,使其拥有一些而外的功能。
实现过程:
一般情况下, 业务类(Business Class) 放到一个单独的模块项目中,因为,一个业务类会在Winform项目中用到,也会在Web应用程序中用到,这样两个项目都可以调用这个模块。
1.先新建一个解决方案,取名MySolution,和上一节讲的一样。
然后右键“MySolution.Module”项目|添加|新建项-》选择Domain Object,取名Contact, (我这里是装了两个版本的)
我们看下生成的代码,打开Contac.cs类,这个类是继承自BaseObject 类的。
2.我们改为如下代码:
[DefaultClassOptions]
[code]public class Contact : Person {
private string webPageAddress;
private string nickName;
private string spouseName;
private TitleOfCourtesy titleOfCourtesy;
private string notes;
private DateTime anniversary;
public Contact(Session session) : base(session) { }
public string WebPageAddress {
get { return webPageAddress; }
set { SetPropertyValue("WebPageAddress", ref webPageAddress, value); }
}
public string NickName {
get { return nickName; }
set { SetPropertyValue("NickName", ref nickName, value); }
}
public string SpouseName {
get { return spouseName; }
set { SetPropertyValue("SpouseName", ref spouseName, value); }
}
public TitleOfCourtesy TitleOfCourtesy {
get { return titleOfCourtesy; }
set { SetPropertyValue("TitleOfCourtesy", ref titleOfCourtesy, value); }
}
public DateTime Anniversary {
get { return anniversary; }
set { SetPropertyValue("Anniversary", ref anniversary, value); }
}
[Size(4096)]
public string Notes {
get { return notes; }
set { SetPropertyValue("Notes", ref notes, value); }
}
}
public enum TitleOfCourtesy { Dr, Miss, Mr, Mrs, Ms };
[/code]
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
这里有几个注意的地方:1应用了[DefaultClassOption]特性。2继承自Person类。3. set访问器 用了SetPropertyValue方法。
defaultclassOption特性有三个方面的作用:业务类被自动生成报表;业务类被加到导航栏中,并且生成ListView视图;能在工具栏生成“新建”按钮
person类也是BaseObject类的子类,也就是说我们的Contact类也是BaseObject的子类,只是间接继承。
SetProperyValue 用于持久化属性;(这是xpo的知识,xpo是xaf的ORM)
3.run ,ok,界面如下:
相关文章推荐
- I do not want to inherit the child opacity from the parent in CSS(不想让子元素继承父元素的透明度)
- #131 – Dependency Properties Inherit Values from Higher Up in the Logical Tree(逻辑树中元素的依赖属性可从其上层元素继承)
- tensorflow运行mnist出现TypeError: A Message class can only inherit from Message
- [Eclipse报错] The type XXX cannot be resolved. It is indirectly referenced from required .class files
- 【ActiveMQ】管理界面查看消息详情,报错/WEB-INF/tags/form/forEachMapEntry.tag PWC6199: Generated servlet error: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- 在kettle6.0中集成插件报错:The type........It is indirectly referenced from required .class files
- The type javax.ws.rs.core.MediaType cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- Truncated class file description The server encountered aninternal error that prevented it from fulf
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- rcp(插件开发)The type XXX cannot be resolved. It is indirectly referenced from required .class files解决办法
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- The type object cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.Object cannot be resolved.It is indirectly referenced from required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.String cannot be resolved. It is indirectly referenced from required .class files
- The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
- The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class fi