/// <summary> /// Gets the property with the given relative binding path /// </summary> /// <param name="context">the context to extend</param> /// <param name="pathExpression">the binding path</param> /// <param name="absolutePath">true if the generated path should be absolute; false otherwise</param> /// <returns>the property value</returns> public static TValue getPropertyFor <TModel, TValue>(this sap.ui.model.Context <TModel> context, Expression <Func <TModel, TValue> > pathExpression, bool absolutePath = true) { string pref = absolutePath ? "/" : ""; string sPropertyName = $"{pref}{ExpressionEvaluator.GetPath(pathExpression)}"; return(context.getProperty <TValue>(sPropertyName)); }
public sap.ui.core.Element productListFactory(string sId, sap.ui.model.Context oContext) { sap.ui.core.Element oUIControl = null; // Decide based on the data which fragment to show if (oContext.getProperty <int>("UnitsInStock") == 0 && oContext.getProperty <bool>("Discontinued")) { // The item is discontinued, so use a StandardListItem if (this._oProductSimple == null) { this._oProductSimple = (sap.ui.core.Control)sap.ui.xmlfragment(sId, "sap.ui.demo.db.view.ProductSimple", this); } oUIControl = _oProductSimple.clone(); } else { // The item is available, so we will create an ObjectListItem if (this._oProductExtended == null) { this._oProductExtended = (sap.ui.core.Control)sap.ui.xmlfragment(sId, "sap.ui.demo.db.view.ProductExtended", this); } oUIControl = this._oProductExtended.clone(); // The item is temporarily out of stock, so we will add a status if (oContext.getProperty <int>("UnitsInStock") < 1) { oUIControl.As <sap.m.ObjectListItem>().addAttribute(new sap.m.ObjectAttribute(new sap.m.ObjectAttribute.Settings() { text = new [email protected]() { path = "i18n>outOfStock" } })); } } return(oUIControl); }