public static IDisposable Bind(Func<XmlBindingArgs, string> f, switch_xml_section_enum_t sections) { switch_xml_search_function_delegate boundFunc = (section, tag, key, keyval, param, userData) => { var args = new XmlBindingArgs { Section = section, TagName = tag, KeyName = key, KeyValue = keyval, Parameters = new switch_event(param, false) }; var xmlStr = f(args); var fsxml = string.IsNullOrEmpty(xmlStr) ? null : freeswitch.switch_xml_parse_str_dynamic(xmlStr, switch_bool_t.SWITCH_TRUE); return switch_xml.getCPtr(fsxml).Handle; }; var fp = Marshal.GetFunctionPointerForDelegate(boundFunc); var swigFp = new SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_switch_event_t_p_void__p_switch_xml(fp, false); var res = freeswitch.switch_xml_bind_search_function_ret(swigFp, (uint)sections, null, null); if (res != switch_status_t.SWITCH_STATUS_SUCCESS) { throw new InvalidOperationException("Call to switch_xml_bind_search_function_ret failed, result: " + res + "."); } return new SwitchXmlSearchBinding(swigFp, boundFunc); }
public static IDisposable Bind(Func <XmlBindingArgs, string> f, switch_xml_section_enum_t sections) { switch_xml_search_function_delegate boundFunc = (section, tag, key, keyval, param, userData) => { var args = new XmlBindingArgs { Section = section, TagName = tag, KeyName = key, KeyValue = keyval, Parameters = new switch_event(param, false) }; var xmlStr = f(args); var fsxml = string.IsNullOrEmpty(xmlStr) ? null : freeswitch.switch_xml_parse_str_dynamic(xmlStr, switch_bool_t.SWITCH_TRUE); return(switch_xml.getCPtr(fsxml).Handle); }; var fp = Marshal.GetFunctionPointerForDelegate(boundFunc); var swigFp = new SWIGTYPE_p_f_p_q_const__char_p_q_const__char_p_q_const__char_p_q_const__char_p_switch_event_t_p_void__p_switch_xml(fp, false); var res = freeswitch.switch_xml_bind_search_function_ret(swigFp, (uint)sections, null, null); if (res != switch_status_t.SWITCH_STATUS_SUCCESS) { throw new InvalidOperationException("Call to switch_xml_bind_search_function_ret failed, result: " + res + "."); } return(new SwitchXmlSearchBinding(swigFp, boundFunc)); }