Exemplo n.º 1
0
        internal static BaseHandle GetManagedBaseHandleFromNativePtr(BaseHandle baseHandle)
        {
            RefObject refObj       = baseHandle.GetObjectPtr();
            IntPtr    refObjectPtr = (IntPtr)RefObject.getCPtr(refObj);

            // we store a dictionary of ref-obects (C++ land) to managed obects (C# land)
            return(GetManagedBaseHandleFromRefObject(refObjectPtr));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes this instance of BaseHandle (C# base class) and native part from the mapping table.
        /// </summary>
        /// <param name="baseHandle"> The instance of BaseHandle (C# base class)</param>
        internal static void Unregister(BaseHandle baseHandle)
        {
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            if (Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Remove(refCptr);
            }

            return;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Removes this instance of BaseHandle (C# base class) and native part from the mapping table.
        /// </summary>
        /// <param name="baseHandle"> The instance of BaseHandle (C# base class)</param>
        internal static void Unregister(BaseHandle baseHandle)
        {
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            RegistryCurrentThreadCheck();
            WeakReference refe;

            if (Instance._controlMap.TryRemove(refCptr, out refe) != true)
            {
                NUILog.Debug("something wrong when removing refCptr!");
            }

            return;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            RegistryCurrentThreadCheck();

            if (Instance._controlMap.TryAdd(refCptr, new WeakReference(baseHandle, false)) != true)
            {
                NUILog.Debug("refCptr is already exist! OR something wrong!");
            }

            return;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            //NUILog.Debug("Storing ref object cptr in control map Hex: {0:X}" + refCptr);

            if (!Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Add(refCptr, new WeakReference(baseHandle, false));
            }

            return;
        }
Exemplo n.º 6
0
        internal static BaseHandle GetManagedBaseHandleFromNativePtr(BaseHandle baseHandle)
        {
            RefObject refObj       = baseHandle.GetObjectPtr();
            IntPtr    refObjectPtr = (IntPtr)RefObject.getCPtr(refObj);

            if (refObjectPtr != null)
            {
                // we store a dictionary of ref-obects (C++ land) to managed obects (C# land)
                return(GetManagedBaseHandleFromRefObject(refObjectPtr));
            }
            else
            {
                NUILog.Error("NUI Registry RefObjectPtr is NULL!");
                return(null);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Stores the mapping between this instance of BaseHandle (C# base class) and native part.
        /// </summary>
        /// <param name="baseHandle">The instance of BaseHandle (C# base class).</param>
        internal static void Register(BaseHandle baseHandle)
        {
            if (savedApplicationThread?.ManagedThreadId != Thread.CurrentThread.ManagedThreadId)
            {
                throw new global::System.ApplicationException("NUI object is attempt to be created in another thread. It should be created in main thread only!");
            }

            // We store a pointer to the RefObject for the control
            RefObject refObj  = baseHandle.GetObjectPtr();
            IntPtr    refCptr = (IntPtr)RefObject.getCPtr(refObj);

            NUILog.Debug("Storing ref object cptr in control map Hex: {0:X}" + refCptr);

            if (!Instance._controlMap.ContainsKey(refCptr))
            {
                Instance._controlMap.Add(refCptr, new WeakReference(baseHandle, false));
            }

            return;
        }