OEA框架学习:元数据设计
一、摘要
目前的框架设计中,引入元数据(metadata)已经是必然的事情,元数据设计原则,EF元数据设计初了MSDN上的还有胡分享的EntityFramework 元数据 设计分析文章写的不错。目前行业提出的DSL(domain specific language)语言,更是把元数据话费得淋漓尽致啊。那OEA里面的元数据是什么样子的呢?!
看了一段时间的OEA了,这次我就给出我眼中的OEA元数据设计架构,大家如果对OEA感兴趣的可以看
http://www.cnblogs.com/zgynhqf
http://openexpressapp.codeplex.com
在OEA中元数据的作用在那里呢?
元数据映射界面设计图
我们已经大致了解到OEA的元数据用在那了,那作者是如何设计的呢?
先给出MetaModel代码目录:
代码结构图:
元数据:
- 实体元数据
- 实体属性元数据
- 实体显示元数据
- 实体显示属性元数据
- 属性元数据
- 子数据元数据
在界面显示上有的属性是不需要显示的 那就需要用户自己进行配置那些可以显示,那些不需要显示。 OEA用的是XML的形式,它的设计如下:
XmlConfig 文件夹 主要就是解决客户化显示问题。
实体与元数据桥梁:
元数据编写规范:
[ChildEntity, Serializable]
public class HouseHold : MyEntity
{
/// <summary>
/// 门牌号
/// </summary>
public static readonly Property<string> HausnummerProperty = P<HouseHold>.Register(e => e.Hausnummer);
public string Hausnummer
{
get { return this.GetProperty(HausnummerProperty); }
set { this.SetProperty(HausnummerProperty, value); }
}
/// <summary>
/// 住户名称
/// </summary>
public static readonly Property<string> NameProperty = P<HouseHold>.Register(e => e.Name);
public string Name
{
get { return this.GetProperty(NameProperty); }
set { this.SetProperty(NameProperty, value); }
}
/// <summary>
/// 面积
/// </summary>
public static readonly Property<string> AreaProperty = P<HouseHold>.Register(e => e.Area);
public string Area
{
get { return this.GetProperty(AreaProperty); }
set { this.SetProperty(AreaProperty, value); }
}
/// <summary>
/// 楼层
/// </summary>
public static readonly Property<string> FloorProperty = P<HouseHold>.Register(e => e.Floor);
public string Floor
{
get { return this.GetProperty(FloorProperty); }
set { this.SetProperty(FloorProperty, value); }
}
#region 所属小区
public static readonly RefProperty<Village> VillageRefProperty =
P<HouseHold>.RegisterRef(e => e.Village, ReferenceType.Parent);
public int VillageId
{
get { return this.GetRefId(VillageRefProperty); }
set { this.SetRefId(VillageRefProperty, value); }
}
public Village Village
{
get { return this.GetRefEntity(VillageRefProperty); }
set { this.SetRefEntity(VillageRefProperty, value); }
}
#endregion
#region 设备列表
public static readonly ListProperty<UDAssociationList> UDAssociationListProperty = P<HouseHold>.RegisterList(e => e.UDAssociationList);
public UDAssociationList UDAssociationList
{
get { return this.GetLazyList(UDAssociationListProperty); }
}
#endregion
#region 民族
public static readonly RefProperty<Nation> NationRefProperty =
P<HouseHold>.RegisterRef(e => e.Nation, ReferenceType.Normal);
public int NationId
{
get { return this.GetRefId(NationRefProperty); }
set { this.SetRefId(NationRefProperty, value); }
}
public Nation Nation
{
get { return this.GetRefEntity(NationRefProperty); }
set { this.SetRefEntity(NationRefProperty, value); }
}
#endregion
}
根据Attributes属性编写的
[ChildEntity, Serializable]
public class HouseHold : MyEntity
{
#region Model
private string _name;
private int _monitoringAreaid;
[Column(Label="住户名称")]
public string Name
{
set { _name = value; }
get { return _name; }
}
[RefProperty(EntityType = typeof(MonitoringArea), ReferenceType = ReferenceType.Normal,Label="区域名称")]
public int MonitoringAreaId
{
set { _monitoringAreaid = value; }
get { return _monitoringAreaid; }
}
#endregion Model
}
元数据相关资料:
http://wenku.baidu.com/view/ee855cfa941ea76e58fa047b.html
http://blog.csdn.net/liwuqing7758/article/details/5688830
http://www.doc88.com/p-208751909019.html
http://wenku.baidu.com/view/8100a2335a8102d276a22f63.html
http://baike.baidu.com/view/624953.htm