Ejemplo n.º 1
0
 public void SetPointerFromObject(ISimObject pObj)
 {
     if (!SimDictionary.Contains(pObj))
     {
         SimDictionary.RegisterObject(pObj);
     }
     ObjectPtr = pObj.ObjectPtr;
 }
Ejemplo n.º 2
0
        public void SetPointer(IntPtr pObjPtr)
        {
            ObjectPtr = pObjPtr;

            if (this is ISimObject sim)
            {
                SimDictionary.RegisterObject(sim);
            }
        }
Ejemplo n.º 3
0
        public void SetPointerFromObject(ConsoleObjectBase pObj)
        {
            ObjectPtr = pObj.ObjectPtr;

            if (this is ISimObject sim && !SimDictionary.Contains(sim))
            {
                SimDictionary.RegisterObject(sim);
            }
        }
Ejemplo n.º 4
0
        public ConsoleObjectBase(bool pRegister = false)
        {
            CreateObjectPtr();
            if (this is ISimObject sim)
            {
                if (pRegister)
                {
                    sim.RegisterObject();
                }

                SimDictionary.RegisterObject(sim);
            }
        }
Ejemplo n.º 5
0
        public static T FindObjectById <T>(uint id) where T : class, ISimObject
        {
            IntPtr objPtr = FindObjectPtrById(id);
            T      obj    = SimDictionary.Find <T>(id);

            if (obj != null && obj.ObjectPtr == objPtr)
            {
                return(obj);
            }
            obj = (T)FormatterServices.GetUninitializedObject(typeof(T));
            obj.SetPointer(objPtr);
            SimDictionary.RegisterObject(obj);
            return(obj);
        }
Ejemplo n.º 6
0
        public static T FindObjectByName <T>(string name) where T : class, ISimObject
        {
            T dictObj = SimDictionary.Find <T>(name);

            if (dictObj != null)
            {
                return(dictObj);
            }
            T obj = (T)FormatterServices.GetUninitializedObject(typeof(T));

            if (obj is IDataBlock)
            {
                IntPtr objPtr = FindDataBlockPtrByName(name);
                if (objPtr == IntPtr.Zero)
                {
                    objPtr = FindObjectPtrByName(name);
                }
                if (objPtr == IntPtr.Zero)
                {
                    return(default(T));
                }
                obj.SetPointer(objPtr);
            }
            else
            {
                IntPtr objPtr = FindObjectPtrByName(name);
                if (objPtr == IntPtr.Zero)
                {
                    return(default(T));
                }
                obj.SetPointer(objPtr);
            }
            if (obj.ObjectPtr == IntPtr.Zero)
            {
                return(default(T));
            }
            SimDictionary.RegisterObject(obj);
            return(obj);
        }