public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propertyParent, TextCode tcKey, string value) { // check the entity parent if (entityTempl == null) { return(null); } PropKeyTemplTextCode propKeyTextCode = new PropKeyTemplTextCode(); propKeyTextCode.TextCodeId = tcKey.Id; // create the property value template PropValueTempl propValue = PropValueTemplTool.CreatePropValueTemplFromValue(value); return(CreatePropTempl(entityTempl, propertyParent, propKeyTextCode, propValue)); }
/// <summary> /// Create a property template, under a property group parent. /// prop key is string, prop value is a bool. /// </summary> /// <param name="entityTempl"></param> /// <param name="tcKey"></param> /// <param name="tcValue"></param> /// <returns></returns> public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propertyParent, string key, bool value) { // check the entity parent if (entityTempl == null) { return(null); } PropKeyTemplString propKeyString = new PropKeyTemplString(); propKeyString.Key = key; // create the property value template, can be null PropValueTempl propValue = PropValueTemplTool.CreatePropValueTemplFromValue(value); return(CreatePropTempl(entityTempl, propertyParent, propKeyString, propValue)); }
//====very generic (low-level) method public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propGroupTemplParent, PropKeyTemplBase propKey, PropValueTempl propValue) { // check the entity parent if (entityTempl == null) { return(null); } if (propGroupTemplParent == null) { propGroupTemplParent = entityTempl.PropertyRoot; } if (propKey == null) { return(null); } string propKeyString = GetPropKeyTemplString(propKey); // check the key, not used by an existing property if (FindPropTemplBaseByKey(entityTempl, propGroupTemplParent, propKeyString) != null) { return(null); } // create the property, set the key and the value PropTempl propertyTempl = new PropTempl(); propertyTempl.PropGroupTemplParentId = propGroupTemplParent.Id; propertyTempl.SetKeyValue(propKey, propValue); // add the property under the root properties entityTempl.AddProperty(propGroupTemplParent, propertyTempl); // save the entity modification if (!_reposit.Builder.UpdateEntityTempl(entityTempl)) { return(null); } return(propertyTempl); }