Tuesday, September 28, 2010

Calculated properties at runtime—TIMES 4

In this post you are going to see how you can use on more of eXpand powerfull features. 4 different ways for creating calculated runtime properties are avaliable.

  1. XPO way –>Using Code
    Take a note at the CreateCalculabeMember extension method at the code bellow

        public class CreateRuntimeCalculatedFieldController : ViewController {

            public override void CustomizeTypesInfo(DevExpress.ExpressApp.DC.ITypesInfo typesInfo) {

                base.CustomizeTypesInfo(typesInfo);

                var classInfo = XafTypesInfo.XpoTypeInfoSource.XPDictionary.GetClassInfo(typeof(Customer));

     

                if (classInfo.FindMember("SumOfOrderTotals")==null) {

                    var attributes = new Attribute[] {new PersistentAliasAttribute("Orders.Sum(Total)")};

                    classInfo.CreateCalculabeMember("SumOfOrderTotals", typeof(float), attributes);

                    typesInfo.RefreshInfo(typeof(Customer));

                }

            }

        }

  2. Using ModelDifference Module
    Setting IsRuntimeMember attribute will create a runtime member and setting the AliasExpression will convert it to a calculated member
    image
    Take a note here that you can easily create calculabe members for the whole application or for a user role or for just one user, depending which type of model is going to host your property
  3. Using WorldCreator extended members
    This approach can be used when u want to decorate your property with more attributes , since WorldCreator  supports much more than the model
    image image
  4. Using a WordCreator Dynamic Assembly
    this approach is the most powerfull one cause allows you also to change the code template as you see in the image bellow

    image

Subscribe to XAF feed
Subscribe to community feed

DiggIt!
blog comments powered by Disqus