static void OnQueryEnded(object sender, EventArgs eventArgs)
        {
            PanelManager.GetOutputPanel(PanelName).QueryEnded -= OnQueryEnded;

            var document = new StringJoiner(
                LinqPadUtilResources.DumpExtendedHead,
                LinqPadUtilResources.DumpExtendedFoot);


            foreach (var renderer in Renderers)
            {
                document.AppendFunc(renderer);
            }

            document.Document.Replace("{script}", LinqPadUtilResources.jquery_1_11_1_min)
            .Replace("{tablesorter}", LinqPadUtilResources.jquery_tablesorter_min)
            .Replace("{firebug}", LinqPadUtilResources.firebug_lite_compressed);

            webBrowser.NavigateToString(document.ToString());

            Renderers.Clear();
            webBrowser = null;
        }
コード例 #2
0
        public static void DumpLive <T>(IObservable <T> obs, string heading)
        {
            ObservablePresenter presenter;
            OutputPanel         outPanel;
            ManualResetEvent    ready;
            IDisposable         extensionToken;
            Server currentServer = Server.CurrentServer;

            if (currentServer != null)
            {
                object obj2;
                presenter = null;
                outPanel  = null;
                ready     = new ManualResetEvent(false);
                Action action = delegate {
                    presenter = new ObservablePresenter();
                    outPanel  = PanelManager.StackWpfElement(WrapInHeading(presenter, heading), "Live &Observables");
                    ready.Set();
                };
                lock ((obj2 = _threadLocker))
                {
                    if (currentServer != _lastServer)
                    {
                        _lastServer = currentServer;
                    }
                    if (currentServer.IsOnMainQueryThread)
                    {
                        action();
                    }
                    else
                    {
                        currentServer.RunOnMessageLoopThread(action);
                    }
                }
                int num = 0;
                while (true)
                {
                    lock ((obj2 = _threadLocker))
                    {
                        if ((((currentServer != _lastServer) || currentServer.MessageLoopEnded) || currentServer.CancelRequest) || (num++ > 20))
                        {
                            return;
                        }
                    }
                    if (ready.WaitOne(500, false))
                    {
                        extensionToken = Util.GetQueryLifeExtensionToken();
                        try
                        {
                            IDisposable subscription = null;
                            CancelToken cancelToken  = new CancelToken();
                            Action      cancel       = delegate {
                                IDisposable disposable1 = subscription;
                                if (disposable1 != null)
                                {
                                    disposable1.Dispose();
                                }
                                else
                                {
                                    cancelToken.Cancel();
                                }
                            };
                            outPanel.QueryEnded += delegate(object sender, EventArgs e) {
                                cancel();
                                if (!(!outPanel.IsQueryCanceled || outPanel.IsPanelClosing))
                                {
                                    presenter.SetCanceled();
                                }
                            };
                            outPanel.PanelClosed += delegate(object sender, EventArgs e) {
                                cancel();
                                extensionToken.Dispose();
                            };
                            Action subscribe = delegate {
                                Action <T>         onNext      = null;
                                Action <Exception> onError     = null;
                                Action             onCompleted = null;
                                try
                                {
                                    if (onNext == null)
                                    {
                                        onNext = val => base.CS$ < > 8__localsd.presenter.SetNext(val);
                                    }
                                    if (onError == null)
                                    {
                                        onError = delegate(Exception ex) {
                                            base.CS$ < > 8__localsd.presenter.SetError(ex);
                                            base.CS$ < > 8__localsd.extensionToken.Dispose();
                                        };
                                    }
                                    if (onCompleted == null)
                                    {
                                        onCompleted = delegate {
                                            base.CS$ < > 8__localsd.presenter.SetComplete();
                                            base.CS$ < > 8__localsd.extensionToken.Dispose();
                                        };
                                    }
                                    subscription = Subscribe <T>(obs, onNext, onError, onCompleted, presenter.Dispatcher, cancelToken);
                                    if (cancelToken.IsCancellationRequested)
                                    {
                                        subscription.Dispose();
                                    }
                                }
                                catch (Exception exception)
                                {
                                    if (subscription != null)
                                    {
                                        subscription.Dispose();
                                    }
                                    if (exception is ThreadAbortException)
                                    {
                                        Thread.ResetAbort();
                                    }
                                    else if (!(exception is OperationCanceledException))
                                    {
                                        Log.Write(exception, "Rx Subscription Failure");
                                        exception.Dump <Exception>();
                                    }
                                }
                            };
                            new Thread(delegate {
                                bool flag = false;
                                try
                                {
                                    flag = RunOnRxScheduler(subscribe);
                                }
                                catch (Exception exception)
                                {
                                    Log.Write(exception);
                                }
                                if (!flag)
                                {
                                    subscribe();
                                }
                            })
                            {
                                IsBackground = true, Name = "Rx Subscriber"
                            }.Start();
                        }
                        catch
                        {
                            extensionToken.Dispose();
                        }
                        return;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: rajeshwarn/TestProject
 private static T Dump <T>(this T o, string description, int?depth, bool toDataGrid, Action <ClickContext> onClick)
 {
     if (o != null)
     {
         Type type = o.GetType();
         if ((((!type.IsValueType && !type.IsPrimitive) && (type.Namespace != null)) && (type.Namespace.StartsWith("System.Threading.Tasks.Dataflow") && (type.GetInterface("System.Threading.Tasks.Dataflow.IDataflowBlock") != null))) && DataflowBridge.Dump(o, description))
         {
             return(o);
         }
     }
     if (depth < 0)
     {
         depth = null;
     }
     if (depth > 20)
     {
         depth = 20;
     }
     if (((depth.HasValue || toDataGrid) || !AppDomain.CurrentDomain.GetAssemblies().Any <Assembly>(a => a.FullName.StartsWith("PresentationCore,", StringComparison.InvariantCultureIgnoreCase))) || !WpfBridge.DumpWpfElement(o, description))
     {
         bool flag2;
         if ((!depth.HasValue && !toDataGrid) && (o is Control))
         {
             if (o is Form)
             {
                 ((Form)o).Show();
                 return(o);
             }
             PanelManager.DisplayControl((Control)o, description ?? "WinForms");
             return(o);
         }
         if ((o is XContainer) || (o is XmlDocument))
         {
             PanelManager.DisplaySyntaxColoredText(o.ToString(), SyntaxLanguageStyle.XML, description ?? "XML");
             return(o);
         }
         Server     currentServer = Server.CurrentServer;
         TextWriter writer        = (currentServer == null) ? null : currentServer.LambdaFormatter;
         Expression expr          = null;
         if (writer != null)
         {
             if (o is IQueryable)
             {
                 expr = ((IQueryable)o).Expression;
             }
             else if (o is Expression)
             {
                 expr = (Expression)o;
             }
         }
         if (expr != null)
         {
             string content = "";
             try
             {
                 ExpressionToken token = ExpressionToken.Visit(expr);
                 if (token != null)
                 {
                     content = token.ToString();
                 }
             }
             catch (Exception exception)
             {
                 Log.Write(exception, "Dump ExpressionToken Visit");
             }
             if (content.Length > 0)
             {
                 lock (writer)
                 {
                     if (!string.IsNullOrEmpty(description))
                     {
                         writer.WriteLine(new HeadingPresenter(description, content));
                     }
                     else
                     {
                         writer.WriteLine(content + "\r\n");
                     }
                 }
             }
         }
         if ((currentServer != null) && currentServer.WriteResultsToGrids)
         {
             toDataGrid = true;
         }
         if (toDataGrid && (o != null))
         {
             Type t = o.GetType();
             if (((!ExplorerGrid.IsAtomic(t) && (!t.IsArray || (t.GetArrayRank() == 1))) && (t.GetInterface("System.IObservable`1") == null)) && (t.GetCustomAttributes(typeof(MetaGraphNodeAttribute), false).Length == 0))
             {
                 return(o.Explore <T>(description));
             }
         }
         XhtmlWriter writer3 = (currentServer == null) ? null : currentServer.ResultsWriter;
         if (flag2 = o is Type)
         {
             ObjectNode.ExpandTypes = true;
         }
         try
         {
             if (!string.IsNullOrEmpty(description))
             {
                 HeadingPresenter presenter = new HeadingPresenter(description, o);
                 if (writer3 != null)
                 {
                     writer3.WriteDepth(presenter, depth, onClick);
                 }
                 else
                 {
                     Console.Write(presenter);
                 }
                 return(o);
             }
             if (writer3 != null)
             {
                 writer3.WriteLineDepth(o, depth, onClick);
             }
             else
             {
                 Console.WriteLine(o);
             }
         }
         finally
         {
             if (flag2)
             {
                 ObjectNode.ExpandTypes = false;
             }
         }
     }
     return(o);
 }