コード例 #1
0
        /// <summary>
        /// Register a REST callback, without locking.
        /// </summary>
        /// <param name="context">OrthancPluginContext*</param>
        /// <param name="pathRegularExpression">const char*</param>
        /// <param name="callback">OrthancPluginRestCallback</param>
        public static void OrthancPluginRegisterRestCallbackNoLock(ref OrthancPluginContext context, IntPtr pathRegularExpression, Callbacks.OrthancPluginRestCallback callback)
        {
            IntPtr ptr = IntPtr.Zero;

            try
            {
                _OrthancPluginRestCallback pr = new _OrthancPluginRestCallback();
                pr.pathRegularExpression = pathRegularExpression;
                pr.callback = callback;

                int size = Marshal.SizeOf(pr);
                ptr = Marshal.AllocHGlobal(size);
                Marshal.StructureToPtr(pr, ptr, true);
                context.InvokeService(ref context, _OrthancPluginService._OrthancPluginService_RegisterRestCallbackNoLock, ptr);
            }
            catch (Exception ex)
            {
                OrthancPluginLogError(ref context, ex.ToString());
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
コード例 #2
0
        /// <summary>
        /// Register a REST callback, without locking.
        /// </summary>
        /// <param name="context">OrthancPluginContext*</param>
        /// <param name="pathRegularExpression">const char*</param>
        /// <param name="callback">OrthancPluginRestCallback</param>
        public static void OrthancPluginRegisterRestCallbackNoLock(ref OrthancPluginContext context, IntPtr pathRegularExpression, Callbacks.OrthancPluginRestCallback callback)
        {
            IntPtr ptr = IntPtr.Zero;
            try
            {
                _OrthancPluginRestCallback pr = new _OrthancPluginRestCallback();
                pr.pathRegularExpression = pathRegularExpression;
                pr.callback = callback;

                int size = Marshal.SizeOf(pr);
                ptr = Marshal.AllocHGlobal(size);
                Marshal.StructureToPtr(pr, ptr, true);
                context.InvokeService(ref context, _OrthancPluginService._OrthancPluginService_RegisterRestCallbackNoLock, ptr);
            }
            catch (Exception ex)
            {
                OrthancPluginLogError(ref context, ex.ToString());
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }