业务对象属性声明与管理详解
在业务对象的开发中,属性的声明和管理是至关重要的环节。下面将详细介绍业务对象属性相关的各种概念、方法和实现细节。
1. 属性转换方法
首先来看一个属性转换的方法:
protected P GetPropertyConvert<F, P>(
PropertyInfo<F> propertyInfo, Security.NoAccessBehavior noAccess)
{
return Utilities.CoerceValue<P>(
typeof(F), null, GetProperty<F>(propertyInfo, noAccess));
}
这个方法和之前的重载方法类似,先获取属性值,然后将其传递给 Utilities.CoerceValue() 方法,将值转换为不同的类型。
2. 子对象引用字段
业务对象可以包含其他业务对象,包含其他对象的是父对象,被包含的是子对象。在父对象中创建引用子对象的属性,通常的代码如下:
private static PropertyInfo<ChildType> ChildProperty =
RegisterProperty(new PropertyInfo<ChildType>("Child"));
public ChildType Child
{
get
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



