/// <summary> /// remove the events for the object in DnObjectsCollection /// </summary> /// <param name="dNObjectsCollectionkey"></param> private void RemoveEvents(int dNObjectsCollectionkey) { Object obj = DNObjectsCollection.GetDNObj(dNObjectsCollectionkey); if (obj != null) { DNObjectEventsCollection.removeEvents(obj); } }
/// <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); } }