public void SetPointerFromObject(ISimObject pObj) { if (!SimDictionary.Contains(pObj)) { SimDictionary.RegisterObject(pObj); } ObjectPtr = pObj.ObjectPtr; }
public void SetPointer(IntPtr pObjPtr) { ObjectPtr = pObjPtr; if (this is ISimObject sim) { SimDictionary.RegisterObject(sim); } }
public void SetPointerFromObject(ConsoleObjectBase pObj) { ObjectPtr = pObj.ObjectPtr; if (this is ISimObject sim && !SimDictionary.Contains(sim)) { SimDictionary.RegisterObject(sim); } }
public ConsoleObjectBase(bool pRegister = false) { CreateObjectPtr(); if (this is ISimObject sim) { if (pRegister) { sim.RegisterObject(); } SimDictionary.RegisterObject(sim); } }
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); }
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); }