示例#1
0
        // Creating these function pointers is a two-stage process.
        // The delegate needs to be stored so it doesn't get GC'd, so we can't just return GetFunctionPointerForDelegate right away.

        /// <summary>Wraps a nice handler into a delegate suitable for reverse P/Invoke. This only currently works well for hangup/reporting handlers.</summary>
        public static switch_state_handler_t_delegate CreateStateHandlerDelegate(ManagedSession sess, Action <ManagedSession> handler)
        {
            // We create a ManagedSession on top of the session so callbacks can use it "nicely"
            // Then we sort of dispose it.
            switch_state_handler_t_delegate del = ptr => {
                handler(sess);
                return(switch_status_t.SWITCH_STATUS_SUCCESS);
            };

            return(del);
        }
示例#2
0
        // Creating these function pointers is a two-stage process.
        // The delegate needs to be stored so it doesn't get GC'd, so we can't just return GetFunctionPointerForDelegate right away.

        /// <summary>Wraps a nice handler into a delegate suitable for reverse P/Invoke. This only currently works well for hangup/reporting handlers.</summary>
        public static switch_state_handler_t_delegate CreateStateHandlerDelegate(Action <ManagedSession> handler)
        {
            // We create a ManagedSession on top of the session so callbacks can use it "nicely"
            // Then we sort of dispose it.
            switch_state_handler_t_delegate del = ptr => {
                using (var sess = new ManagedSession(new SWIGTYPE_p_switch_core_session(ptr, false))) {
                    handler(sess);
                    return(switch_status_t.SWITCH_STATUS_SUCCESS);
                }
            };

            return(del);
        }
示例#3
0
 public static SWIGTYPE_p_f_p_switch_core_session__switch_status_t WrapStateHandlerDelegate(switch_state_handler_t_delegate del)
 {
     return(new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(Marshal.GetFunctionPointerForDelegate(del), false));
 }
 public static SWIGTYPE_p_f_p_switch_core_session__switch_status_t WrapStateHandlerDelegate(switch_state_handler_t_delegate del) {
     return new SWIGTYPE_p_f_p_switch_core_session__switch_status_t(Marshal.GetFunctionPointerForDelegate(del), false);
 }