Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// creates a DNMemberInfo for object at key 'obj', add into DNMemberInfoTable and returns key
        /// </summary>
        /// <param name="key">key to DNObjectsCollection</param>
        /// <returns></returns>
        public DNMemberInfo CreateDNMemberInfo(int key)
        {
            Type dnObjType = null;

            // get the dotnet object
            object dnObj = DNObjectsCollection.GetDNObj(key);

            // get the type
            if (dnObj != null)
            {
                dnObjType = ReflectionServices.GetType(dnObj);
            }

            // create a DNMemberInfo
            var dnMemberInfo = new DNMemberInfo(dnObjType, dnObj, null, key, null);

            return(dnMemberInfo);
        }
Ejemplo n.º 4
0
        /// <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);
            }
        }