Exemplo n.º 1
0
        protected T invokeCallback <T>(string name, RecognizerCallback <T> callback, Func <string> debugReport = null)
        {
            D.assert(callback != null);

            T result = default(T);

            try {
                D.assert(() => {
                    if (D.debugPrintRecognizerCallbacksTrace)
                    {
                        var report = debugReport != null ? debugReport() : null;
                        // The 19 in the line below is the width of the prefix used by
                        // _debugLogDiagnostic in arena.dart.
                        var prefix = D.debugPrintGestureArenaDiagnostics ? new string(' ', 19) + "❙ " : "";
                        Debug.LogFormat("{0}this calling {1} callback.{2}",
                                        prefix, name, report.isNotEmpty() ? " " + report : "");
                    }

                    return(true);
                });

                result = callback();
            }
            catch (Exception ex) {
                IEnumerable <DiagnosticsNode> infoCollector()
                {
                    yield return(new StringProperty("Handler", name));

                    yield return(new DiagnosticsProperty <GestureRecognizer>("Recognizer", this, style: DiagnosticsTreeStyle.errorProperty));
                }

                UIWidgetsError.reportError(new UIWidgetsErrorDetails(
                                               exception: ex,
                                               library: "gesture",
                                               context: new ErrorDescription("while handling a gesture"),
                                               informationCollector: infoCollector
                                               ));
            }

            return(result);
        }
Exemplo n.º 2
0
        protected T invokeCallback <T>(string name, RecognizerCallback <T> callback, Func <string> debugReport = null)
        {
            D.assert(callback != null);

            T result = default(T);

            try {
                D.assert(() => {
                    if (D.debugPrintRecognizerCallbacksTrace)
                    {
                        var report = debugReport != null ? debugReport() : null;
                        // The 19 in the line below is the width of the prefix used by
                        // _debugLogDiagnostic in arena.dart.
                        var prefix = D.debugPrintGestureArenaDiagnostics ? new string(' ', 19) + "❙ " : "";
                        Debug.LogFormat("{0}this calling {1} callback.{2}",
                                        prefix, name, report.isNotEmpty() ? " " + report : "");
                    }

                    return(true);
                });

                result = callback();
            }
            catch (Exception ex) {
                UIWidgetsError.reportError(new UIWidgetsErrorDetails(
                                               exception: ex,
                                               library: "gesture",
                                               context: "while handling a gesture",
                                               informationCollector: information => {
                    information.AppendLine("Handler: " + name);
                    information.AppendLine("Recognizer:");
                    information.AppendLine("  " + this);
                }
                                               ));
            }

            return(result);
        }