/// <summary>clear (set to null) objects stored in DNObjectsCollection</summary> /// <param name="keys">an array of keys to be cleared</param> /// <param name="removeEvent">if true, removes event on the objects</param> public void ClearDNObjectsCollectionEntries(int[] keys, bool removeEvent) { foreach (int key in keys) { if (removeEvent) { RemoveEvents(key); } DNObjectsCollection.Update(key, null); } }
/// <summary> /// Duplicates a DNObjectsCollection entry and returns the new key /// </summary> /// <param name="key"></param> /// <returns></returns> public int DuplicateDNObjectsCollectionEntry(int sourceKey) { String[] currentTaskDNEventsNames = DNObjectsCollection.GetCurrentTaskDNEventsNames(sourceKey); Object sourceObj = DNObjectsCollection.GetDNObj(sourceKey); Type sourceDNType = DNObjectsCollection.GetDNType(sourceKey); int key = DNObjectsCollection.CreateEntry(sourceDNType); DNObjectsCollection.Update(key, sourceObj); DNObjectEventsCollection.addEvents(sourceObj, currentTaskDNEventsNames); return(key); }
/// <summary>Updates specified entry in DNObjectCollection table</summary> /// <param name="destKey">Destination entry key</param> /// <param name="srcObj">Source .net object</param> /// <returns></returns> public void UpdateDNObject(int destKey, Object srcObj) { // for controls, events are queried from MgGui.dll when the control is created. String[] currentTaskDNEventsNames = DNObjectsCollection.GetCurrentTaskDNEventsNames(destKey); Object destObj = DNObjectsCollection.GetDNObj(destKey); Type destDNType = DNObjectsCollection.GetDNType(destKey); // perform a cast into Type 'destDNType' if (destDNType != null) { srcObj = DNConvert.doCast(srcObj, destDNType); } // check if the object has changed bool valsEqual = (srcObj == destObj || srcObj != null && destObj != null && srcObj.Equals(destObj)); if (!valsEqual) { // update the object into DNObjectCollection DNObjectsCollection.Update(destKey, srcObj); DNObjectEventsCollection.removeEvents(destObj); DNObjectEventsCollection.addEvents(srcObj, currentTaskDNEventsNames); } }