星空网 > 软件开发 > ASP.net

XAF应用开发教程

在 XAF 框架,一些用来生成一个业务应用程序的信息是在Attribute中指定。您可以将属性应用到业务类 (或它的成员) 指定验证规则,指定如何对数据进行显示、 设置关系类等。本主题提供了有关在何处以及如何可以应用这些属性的内置 XAF 框架属性和信息的列表。

 

Attribute

说明

ActionAttribute在业务对象上书写方法,并在方法上面加上这个Attribute,在界面上,会出现一个简单按钮或弹出窗口按钮.
AppearanceAttribute在业务类或方法\属性上面书写此Attribute,可以控制相关的外观控制,比如:控件是否禁用,是否只读,背景颜色变化,字体,按钮是否可用等.
AggregatedAttribute在XPCollection<T>类型的属性上面写,可以控制主从表结构的业务对是否为聚合关系. 什么聚合?就是主对象与子对象放到一起对应着业务上的一个内容,比如,订单,订单明细,这两个表放到一起才是完整的.
CalculatedAttribute在属性上面写,属性的结果将是计算而来的.
CalculatedPersistentAliasAttributeApplied to a business class. Allows you to dynamically configure a persistent alias for the target business class' property.
CaptionsForBoolValuesAttribute在布尔类型的属性上面写,可以指定true,false的值显示为指定的值,比如,换成男/女,真/假,是/否.但不要把这个做为汉化之用.
CodeRuleAttributeApplied to a validation rule. Specifies that the rule is intended for a particular business class and does not have a corresponding validation attribute.
CollectionSourceModeAttributeSpecifies the mode of operation for the Collection Sources created by List Property Editors representing the CollectionSourceModeAttribute's target property.
CreateInstanceAttributeSpecifies that a Domain Component's target method will create Domain Component instances.
CreatableItemAttribute在BO/DC上面写,在web下面与win下面不太一样.可以快速新建菜单上显示这个BO.
CriteriaOptionsAttribute当使用条件编辑器时,在这里指定一些选项,比如,条件应用到哪个BO上面.
DataSourceCriteriaAttribute可以应用于BO类型的属性,或XPCollection<T>上面,指定选择(Link,链接)对象时,用什么条件去过滤数据源,比如,有个客户属性,选择客户时,某一场景中需要显示出所有年龄在30到50中间的客户.
DataSourceCriteriaPropertyAttribute与上面的功能相同,但这个条件不是写死的,是从另一个属性中读过来的.这样可以在那个属性中动态的接出条件来.
DataSourcePropertyAttribute功能与上面两个类型,但直接从某个属性中指定可选择的数据来源了,更加动态了,不过要考虑性能问题还是少用为好,因为程序员拼出来的数据源,说不准怎么来的.
DefaultClassOptionsAttribute加上这个后,BO就在导航栏上出现了,快速新建按钮也有了,报表中也会出现,我只观察到了这么多,这个就是个快捷方式.
DefaultListViewOptionsAttribute在BO上面写,一些常见的默认列表视图的控制.
DelayedAttribute在属性上写,延迟加载该属性.官方说是EF用的.但我在xpo中也用过啊!
DetailViewLayoutAttribute在属性上写,供在BO上对详细视图进行简单的布局.
DomainComponentAttribute在接口上写,表明这是一个DC,在非持久化的BO上面写,表明让系统生成这个BO的视图.
ExpandObjectMembersAttribute写在复杂类型的属性上面,可以将属性类型中的属性展开,在视图上直接显示出来.比如,客户.地址.详细地址,与详细地址同级别的还有一堆的属性,用了这个后就可以一次性的显示出来了.
FieldSizeAttribute字符型属性在库中建立字段时的长度,-1为不限长.
FileAttachmentAttribute应用到类上,表明值是文件类型,需要实现IFileData接口.
FileTypeFilterAttribute在上传文件时,如何过滤文件名?扩展名?
FriendlyKeyPropertyAttributeSpecifies a property that is considered an analog of the GUID property to allow the use of more suitable values.
ImageEditorAttribute图像编辑器的一些设置.
ImageNameAttribute写在BO上面,设置一个图标,在列表上,详细视图上,都可以看到这个图标.
ImagesForBoolValuesAttribute写在布尔型属性上面,可以指定布尔型值的图标,比如true用一个对号,false用一个叉叉.
ImmediatePostDataAttribute在web下面有用,写在属性上,指示当值发生变化时,是否需要回发到服务端,比如, 总价=单价*数量,那么,单位,数量变化时,总价需要做个计算,那么就要在单价,数量上面加上这个Attribute.
IndexAttribute在属性上面写,建表时,建个索引出来,为性能捉想.
KeyAttribute写在属性上面,指示这个属性就是主键.
ListEditorAttribute指定要使用的列表控件.
ListViewFilterAttribute给列表内置一些过滤条件,在界面上显示一个下拉框,一选,就过滤啦.
LookupEditorModeAttribute指示搜索对话框长什么样子,比如全部显示在下拉框中,或是弹出个窗口,或是自动,自动是指超过25条(可改)则显示弹出框.自动会有些性能影响,因为要算当前有多少条数据.
ModelDefaultAttribute在代码中写ModelEditor中的默认值,很多东东可以用这个设置了,并且可以替换掉一些前面的属性,比如本来可以用[XafDisplayName("显示名")]改为[ModelDefault("Caption","显示名")].至于Caption这个关键字要怎样知道,可以打开ModelDeditor查看.
ModelNodesGeneratorAttribute自己写个类,是生成模型的,需要加这个.具体还是需要好几步的.
NavigationItemAttribute某个BO是否显示在导航栏中.
NonCloneableAttribute克隆模块:不允许这个BO克隆.
NotClonedInfoAttributeApplied to a business class. Specifies a business class' string property that can hold property values that were not cloned.
ObjectCaptionFormatAttribute指示在详细视图中Bo的显示标题
PropertyEditorAttribute要使用什么编辑器,默认都是自动的,只有想改变默认时才用这个.
Attributes from the Validation module:
RuleBaseAttribute, 
RuleCombinationOfPropertiesIsUniqueAttribute, 
RuleCriteriaAttribute, 
RuleFromBoolPropertyAttribute, 
RuleIsReferencedAttribute, 
RuleObjectExistsAttribute, 
RuleRangeAttribute, 
RuleRegularExpressionAttribute, 
RuleRequiredFieldAttribute, 
RuleStringComparisonAttribute, 
RuleUniqueValueAttribute, 
RuleValueComparisonAttribute.

这几个都是做验证规则用的.

RuleCombinationOfPropertiesIsUniqueAttribute 组合唯一,在类上面,指定多个属性,这些属性是组合唯一的.

RuleCriteriaAttribute, 在类上面,数据必须满足指定的条件.

RuleFromBoolPropertyAttribute, 在布尔型属性上面,值必须为真.

RuleObjectExistsAttribute, 指定的对象必须存在.

RuleRangeAttribute, 属性的值必须在指定的范围内.

RuleRegularExpressionAttribute, 属性的值必须满足正则表达式的要求.

RuleRequiredFieldAttribute, 属性是必填的.

RuleStringComparisonAttribute, 属性的值和字符串进行比较.

RuleUniqueValueAttribute, 属性的值必须是唯一的.

RuleValueComparisonAttribute.属性的值和指定的值(另一个属性)进行比较.

SearchClassOptionsAttribute用于全文检索的一些选项.
SearchMemberOptionsAttribute也是全文检索用的,设置哪些字段参与或不参与.
ToolTipAttribute属性的提示文字.
ViewItemAttributeApplied to a custom View Item. Registers a View Item in an application and specifies the type of the Application Model's node used by a custom View Item.
VisibleInDetailViewAttribute属性在详细视图中是否可见
VisibleInListViewAttribute属性在列表视图中是否可见
VisibleInLookupListViewAttribute属性在搜索视图中是否可见.
VisibleInReportsAttribute做报表时是否可以选择这个BO.
XafDefaultPropertyAttribute默认属性,在引用类型被用于属性时,用该引用类的哪个字段做为显示标题. 比如,订单中的客户,选择完成后,应该显示客户姓名,那么[XafDefaultPropety("姓名")]写在客户BO上面即可.
XafDisplayNameAttribute指定显示名称,比如BO叫Customer,[XafDisplayName("客户")],写到BO上面.

你也可以使用一些属性是.net 提供的(比如 BrowsableAttribute, DefaultPropertyAttribute  DisplayNameAttribute)

下面的列表是在 System.ComponentModel 命名空间下的,在XAF中他们是有效的.

Attribute

说明

备注

BrowsableAttribute属性是否可见,指定为false后,相当于详细视图,列表视图,搜索视图,都不可见了.就相当于一个快捷方式.通常是要隐藏一个属性时用它.
DefaultPropertyAttribute和XafDefaultPropertyAttribute是一样的.:
  • 显示在搜索编辑器中;
  • 对象的标题,比如详细视图中;
  • 全文检索中也会被用到;
  • 显示在列表视图的第一列.
 
DescriptionAttribute做自定义模块时会用到.指示模块的备注信息 
DisplayNameAttribute

与 XafDisplayNameAttribute 相同.

 
PasswordPropertyTextAttribute在字符串属性上面写,编辑器就变成了密码输入框. 

 






原标题:XAF应用开发教程

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流