文章目錄
- 應用程式模型貫穿於整個架構層
- 模型關注what
- ApplicationModel
- Command模型
為OpenExpressApp的系統架構圖,其中在應用程式模型是作為一種中繼資料貫穿於整個架構,應用程式模型運行在OpenExpressApp架構之上。應用程式模型是OEA的核心,理解好應用程式模型才能更好的使用OEA。
應用程式模型貫穿於整個架構層模型關注what
OEA希望從重複的技術工作中脫離出來,在經過大量實踐基礎之上對一些常用功能進行抽象,整理和總結出一些通用模型,在基於模型的描述下,我們更加關注的是what,而不是how。OpenExpressApp平台建模工具計劃支援企業架構建模(EA)、介面建模(UI)、命令擴充(Command)、領域建模(Domain)、規則建模(Rule)、報表模型(Report)和工作流程模型(Workflow)。目前OEA的應用程式模型主要有UI模型和Command模型。
模型可以通過多種方式定義,如代碼、屬性標識和建模等,目前OEA支援類屬性標識產生應用程式模型,這個一般用在簡單應用軟體中,計劃加入建模工具,那時就不需要在類庫中標識UI模型了。
ApplicationModel
既然我們使用模型來開發,那麼必然會有一個存放模型的地方,在OEA中UI模型和Command模型都統一放置在ApplicationModel靜態類中。
Code
/// 應用程式模型
public static class ApplicationModel
{
/// 應用程式中所有的命令對象
public static readonly CommandCollection Commands = new CommandCollection();
/// 預設的所有業務物件模型集合 public static readonly ObservableCollection<BusinessObjectInfo> DefaultBusinessObjectInfos = new ObservableCollection<BusinessObjectInfo>();
/// 尋找指定類型對應的業務物件模型中繼資料, 如果沒有尋找到,則產生並儲存一個新的。
public static BusinessObjectInfo AddBusinessObject(Type boType)
{
BusinessObjectInfo info = null;
BusinessObjectInfoDict.TryGetValue(boType, out info);
if (info == null)
{
info = new BusinessObjectInfo(boType);
BusinessObjectInfoDict.Add(boType, info);
if (info.IsDefaultObject)
{
DefaultBusinessObjectInfos.Add(info);
}
}
return info;
}
public static BusinessObjectInfo GetBusinessObjectInfo(Type boType)
{
BusinessObjectInfo info = null;
BusinessObjectInfoDict.TryGetValue(boType, out info);
if (null == info)
{
info = AddBusinessObject(boType);
}
return info;
}
}
應用程式模型中有三個重要的類:
- BusinessObjectInfo:業務對象資訊,通過ApplicationModel.AddBusinessObject調用
- BusinessObjectPropertyInfo:屬性資訊,在BusinessObjectInfo建構函式中產生
- BusinessObjectsPropertyInfo:子物件屬性資訊,在BusinessObjectInfo建構函式中產生
Code
public BusinessObjectInfo(Type boType)
{
...
foreach (PropertyInfo item in boType.GetProperties())
{
if (item.HasMarked<EntityPropertyAttribute>())
{
BOPropertyInfos.Add(new BusinessObjectPropertyInfo(item, this));
}
if (item.HasMarked<AssociationAttribute>())
{
AssociationAttribute attr = item.GetSingleAttribute<AssociationAttribute>();
BOsPropertyInfos.Add(new BusinessObjectsPropertyInfo(item, attr, this));
if (attr.ShowInTree)
{
TreeChildPropertyInfo = item;
}
}
}
}UI模型
資訊系統開發平台OpenExpressApp - 內建支援的屬性編輯方式
資訊系統開發平台OpenExpressApp - 內建支援的列表編輯方式
資訊系統開發平台OpenExpressApp - 理解核心元素ObjectView
資訊系統開發平台OpenExpressApp - AutoUI自動產生介面
Command模型
資訊系統開發平台OpenExpressApp - Command擴充機制
更多內容: 開源資訊系統開發平台之OpenExpressApp架構.pdf
歡迎轉載,轉載請註明:轉載自周金根 [ http://zhoujg.cnblogs.com/ ]