From d378ff132a710a76a56a8a1a8675f0d664649531 Mon Sep 17 00:00:00 2001 From: apobekiaris Date: Wed, 30 Jan 2013 19:15:31 +0200 Subject: [PATCH] Refactor according to blog post: http://community.devexpress.com/blogs/eaf/archive/2013/01/29/dynamic-member-aliases-from-application-model.aspx --- .../CreateRuntimeCalculatedFieldController.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Demos/FeatureCenter/FeatureCenter.Module/RuntimeFields/CalculatedWithCode/CreateRuntimeCalculatedFieldController.cs b/Demos/FeatureCenter/FeatureCenter.Module/RuntimeFields/CalculatedWithCode/CreateRuntimeCalculatedFieldController.cs index f46313abea..79c4ca4b56 100644 --- a/Demos/FeatureCenter/FeatureCenter.Module/RuntimeFields/CalculatedWithCode/CreateRuntimeCalculatedFieldController.cs +++ b/Demos/FeatureCenter/FeatureCenter.Module/RuntimeFields/CalculatedWithCode/CreateRuntimeCalculatedFieldController.cs @@ -1,7 +1,6 @@ using System; using DevExpress.ExpressApp; using DevExpress.Persistent.Base; -using DevExpress.Xpo; using Xpand.ExpressApp; using Xpand.Xpo; @@ -10,11 +9,15 @@ public class CreateRuntimeCalculatedFieldController : ViewController { public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo) { base.CustomizeTypesInfo(typesInfo); var classInfo = XpandModuleBase.Dictiorary.GetClassInfo(typeof(Customer)); - - if (classInfo.FindMember("SumOfOrderTotals")==null) { + + if (classInfo.FindMember("SumOfOrderTotals") == null) { + var xpandCalcMemberInfo = classInfo.CreateCalculabeMember("SumOfOrderTotals", typeof(float), "Orders.Sum(Total)"); var attributes = new Attribute[] {new VisibleInListViewAttribute(false),new VisibleInLookupListViewAttribute(false), - new VisibleInDetailViewAttribute(false),new PersistentAliasAttribute("Orders.Sum(Total)")}; - classInfo.CreateCalculabeMember("SumOfOrderTotals", typeof(float), attributes); + new VisibleInDetailViewAttribute(false)}; + foreach (var attribute in attributes) { + xpandCalcMemberInfo.AddAttribute(attribute); + } + typesInfo.RefreshInfo(typeof(Customer)); } }