private void FlashWrapper_FlashCall(object sender, FlashCallEventArgs args) { _flashCallingOut = true; try { if (args.Handled) { return; // Already handled } using (NDC.Push(_flashSessionID)) { string methodName; object[] parameters; if (!TryDeserializeMethodInvokeMessage(args.Request, out methodName, out parameters)) { return; // We don't know of this method } MethodInfo targetMethodInfo; if (!_callbackTable.TryGetValue(methodName.ToLower(), out targetMethodInfo)) { _log.ErrorFormat("Did not find a .NET callback method named '{0}'", methodName); return; } object result; try { _log.DebugFormat("Flash Invoking method '{0}'", methodName); result = _flashInterface.GetType().InvokeMember(targetMethodInfo.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.InvokeMethod, null, _flashInterface, parameters); } catch (Exception ex) { _log.ErrorFormat("Exception invoking '{0}' from Flash: {1}", methodName, ex); throw; } if (targetMethodInfo.ReturnType == typeof(void)) { if (UserSettings.Default.LogFlash && !_log.IsDebugEnabled) { _log.InfoFormat("Flash invoked method '{0}'", methodName); } args.Handled = true; _flashWrapper.SetReturnValue("<undefined/>"); return; } var stringBuilder = new StringBuilder(); using (var xmlWriter = XmlWriter.Create(stringBuilder, s_xmlWriterSettings)) { Serialize(xmlWriter, result); } var returnXml = stringBuilder.ToString(); _flashWrapper.SetReturnValue(returnXml); if (UserSettings.Default.LogFlash) { if (_log.IsDebugEnabled) { _log.DebugFormat("Flash invoked method '{0}' returning xml value '{1}'", methodName, returnXml); } else { _log.InfoFormat("Flash invoked method '{0}' returning '{1}'", methodName, result ?? "<null>"); } } args.Handled = true; } } finally { _flashCallingOut = false; } }
private void AxShockwaveFlashOnFlashCall(object sender, _IShockwaveFlashEvents_FlashCallEvent e) { EventHandler<FlashCallEventArgs> eventHandler = FlashCall; if (eventHandler == null) { return; } var args = new FlashCallEventArgs(e, false); eventHandler(sender, args); if (!args.Handled && UnhandledFlashCallback != null) { UnhandledFlashCallback(e.request); } }