Ejemplo n.º 1
0
 public Client(QueryCore query, string querySelection, bool compileOnly, QueryCompilationEventArgs lastCompilation, Func<Client, Server> serverGenerator, PluginWindowManager pluginWinManager)
 {
     this._query = query;
     this._partialSource = !string.IsNullOrEmpty(querySelection);
     this._source = this._partialSource ? querySelection : this._query.Source;
     this._compileOnly = compileOnly;
     this._lastCompilation = lastCompilation;
     this._serverGenerator = serverGenerator;
     this._pluginWinManager = pluginWinManager;
 }
Ejemplo n.º 2
0
 private void _client_QueryCompiled(object sender, QueryCompilationEventArgs e)
 {
     lock (this._executionLock)
     {
         if (this._client == sender)
         {
             this._queryStarting = false;
             if (e.Errors.HasErrors)
             {
                 this._queryWatch.Stop();
             }
             else
             {
                 if (e.AssemblyPDB != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyPDB);
                 }
                 if (e.DataContextDLL != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.DataContextDLL);
                 }
                 if (e.AssemblyDLL != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyDLL);
                 }
                 if (e.AssemblyPDB != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyPDB);
                 }
                 this.AddAssemblyPressure((int)new FileInfo(e.AssemblyDLL.FullPath).Length);
                 base.RequiresRecompilation = false;
             }
             if (this.QueryCompiled != null)
             {
                 this.QueryCompiled(this, e);
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void _client_QueryCompiled(object sender, QueryCompilationEventArgs e)
 {
     lock (this._executionLock)
     {
         if (this._client == sender)
         {
             this._queryStarting = false;
             if (e.Errors.HasErrors)
             {
                 this._queryWatch.Stop();
             }
             else
             {
                 if (e.AssemblyPDB != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyPDB);
                 }
                 if (e.DataContextDLL != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.DataContextDLL);
                 }
                 if (e.AssemblyDLL != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyDLL);
                 }
                 if (e.AssemblyPDB != null)
                 {
                     this.RegisterRemoteAssemblyFile(e.AssemblyPDB);
                 }
                 this.AddAssemblyPressure((int) new FileInfo(e.AssemblyDLL.FullPath).Length);
                 base.RequiresRecompilation = false;
             }
             if (this.QueryCompiled != null)
             {
                 this.QueryCompiled(this, e);
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void Run(string querySelection, bool compileOnly, QueryCompilationEventArgs lastCompiler, LINQPad.UI.PluginWindowManager winManager)
 {
     lock (this._executionLock)
     {
         FileWithVersionInfo[] infoArray;
         FileWithVersionInfo[] infoArray2;
         if (this.IsRunning)
         {
             return;
         }
         this.GetAssemblyReferenceMap(out infoArray, out infoArray2);
         bool flag2 = this.NeedsRefresh(this._lastVolatileRefs, infoArray);
         bool flag3 = this.NeedsRefresh(this._lastNonvolatileRefs, infoArray2);
         bool flag4 = (!flag2 && (this._lastVolatileRefs != null)) && (this._lastVolatileRefs.Length > infoArray.Length);
         this._lastVolatileRefs    = infoArray;
         this._lastNonvolatileRefs = infoArray2;
         if (flag2 || flag3)
         {
             this.PolluteCachedDomain(true);
         }
         if (this._client != null)
         {
             if ((this._cachedDomainPolluted || Program.FreshAppDomains) || ((!Program.PreserveAppDomains && !this.IsUserCachePresent()) && (((this._loadedAssemblyCount > 40) || (this._cumulativeFootprint > 0x1312d00L)) || this._client.LastWorkerThreadAborted())))
             {
                 this._client.Cancel(false, true);
                 this._cachedDomain = null;
             }
             this._client.Dispose();
         }
         this._queryStarting = true;
         this._querySnapshot = this.GetSnapshotForExecution();
         if ((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Program))
         {
             if (querySelection.TrimEnd(new char[0]).EndsWith(";"))
             {
                 this._querySnapshot.QueryKind = QueryLanguage.Statements;
             }
             else if (!(querySelection.Trim().Contains("\n") && querySelection.Contains <char>('{')))
             {
                 this._querySnapshot.QueryKind = QueryLanguage.Expression;
             }
         }
         else if (((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Statements)) && !querySelection.Contains <char>(';'))
         {
             this._querySnapshot.QueryKind = QueryLanguage.Expression;
         }
         this._client = new Client(this._querySnapshot, querySelection, compileOnly, lastCompiler, new Func <Client, Server>(this.CreateServer), winManager);
         this._client.QueryCompiled       += new EventHandler <QueryCompilationEventArgs>(this._client_QueryCompiled);
         this._client.QueryCompleted      += new EventHandler <QueryStatusEventArgs>(this._client_QueryCompleted);
         this._client.ReadLineRequested   += new EventHandler <ReadLineEventArgs>(this._client_ReadLineRequested);
         this._client.PluginsReady        += new EventHandler(this._client_PluginsReady);
         this._client.CustomClickComplete += new EventHandler(this._client_CustomClickComplete);
         if (this.AllowShadow())
         {
             Stopwatch stopwatch = Stopwatch.StartNew();
             if (flag2)
             {
                 this.CreateShadow();
             }
             else if (flag4)
             {
                 this.UpdateShadow();
             }
             stopwatch.Stop();
         }
     }
     ThreadPool.QueueUserWorkItem(delegate(object _) {
         try
         {
             base.AutoSave(true);
         }
         catch
         {
         }
     });
     new Thread(new ThreadStart(this._client.Start))
     {
         IsBackground = true, Name = "Query Starter"
     }.Start();
     this._queryWatch.Reset();
     this._queryWatch.Start();
 }
Ejemplo n.º 5
0
 protected virtual void OnQueryCompiled(QueryCompilationEventArgs e)
 {
     EventHandler<QueryCompilationEventArgs> queryCompiled = this.QueryCompiled;
     if (queryCompiled != null)
     {
         queryCompiled(this, e);
     }
     this.QueryCompiled = null;
 }
Ejemplo n.º 6
0
 public void Run(string querySelection, bool compileOnly, QueryCompilationEventArgs lastCompiler, LINQPad.UI.PluginWindowManager winManager)
 {
     lock (this._executionLock)
     {
         FileWithVersionInfo[] infoArray;
         FileWithVersionInfo[] infoArray2;
         if (this.IsRunning)
         {
             return;
         }
         this.GetAssemblyReferenceMap(out infoArray, out infoArray2);
         bool flag2 = this.NeedsRefresh(this._lastVolatileRefs, infoArray);
         bool flag3 = this.NeedsRefresh(this._lastNonvolatileRefs, infoArray2);
         bool flag4 = (!flag2 && (this._lastVolatileRefs != null)) && (this._lastVolatileRefs.Length > infoArray.Length);
         this._lastVolatileRefs = infoArray;
         this._lastNonvolatileRefs = infoArray2;
         if (flag2 || flag3)
         {
             this.PolluteCachedDomain(true);
         }
         if (this._client != null)
         {
             if ((this._cachedDomainPolluted || Program.FreshAppDomains) || ((!Program.PreserveAppDomains && !this.IsUserCachePresent()) && (((this._loadedAssemblyCount > 40) || (this._cumulativeFootprint > 0x1312d00L)) || this._client.LastWorkerThreadAborted())))
             {
                 this._client.Cancel(false, true);
                 this._cachedDomain = null;
             }
             this._client.Dispose();
         }
         this._queryStarting = true;
         this._querySnapshot = this.GetSnapshotForExecution();
         if ((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Program))
         {
             if (querySelection.TrimEnd(new char[0]).EndsWith(";"))
             {
                 this._querySnapshot.QueryKind = QueryLanguage.Statements;
             }
             else if (!(querySelection.Trim().Contains("\n") && querySelection.Contains<char>('{')))
             {
                 this._querySnapshot.QueryKind = QueryLanguage.Expression;
             }
         }
         else if (((querySelection != null) && (this._querySnapshot.QueryKind == QueryLanguage.Statements)) && !querySelection.Contains<char>(';'))
         {
             this._querySnapshot.QueryKind = QueryLanguage.Expression;
         }
         this._client = new Client(this._querySnapshot, querySelection, compileOnly, lastCompiler, new Func<Client, Server>(this.CreateServer), winManager);
         this._client.QueryCompiled += new EventHandler<QueryCompilationEventArgs>(this._client_QueryCompiled);
         this._client.QueryCompleted += new EventHandler<QueryStatusEventArgs>(this._client_QueryCompleted);
         this._client.ReadLineRequested += new EventHandler<ReadLineEventArgs>(this._client_ReadLineRequested);
         this._client.PluginsReady += new EventHandler(this._client_PluginsReady);
         this._client.CustomClickComplete += new EventHandler(this._client_CustomClickComplete);
         if (this.AllowShadow())
         {
             Stopwatch stopwatch = Stopwatch.StartNew();
             if (flag2)
             {
                 this.CreateShadow();
             }
             else if (flag4)
             {
                 this.UpdateShadow();
             }
             stopwatch.Stop();
         }
     }
     ThreadPool.QueueUserWorkItem(delegate (object _) {
         try
         {
             base.AutoSave(true);
         }
         catch
         {
         }
     });
     new Thread(new ThreadStart(this._client.Start)) { IsBackground = true, Name = "Query Starter" }.Start();
     this._queryWatch.Reset();
     this._queryWatch.Start();
 }
Ejemplo n.º 7
0
 private void _query_QueryCompiled(object sender, QueryCompilationEventArgs e)
 {
     this.BeginInvoke(delegate {
         try
         {
             this.QueryCompiled(e);
         }
         catch (Exception exception)
         {
             Program.ProcessException(exception);
         }
     });
 }
Ejemplo n.º 8
0
 private void QueryCompiled(QueryCompilationEventArgs e)
 {
     Func<CompilerError, string> selector = null;
     Func<CompilerError, bool> predicate = null;
     CompilerError mainError;
     CompilerError[] mainErrors;
     if (!base.IsDisposed)
     {
         this._lastCompilation = e;
         IEnumerable<CompilerError> source = from er in e.Errors.Cast<CompilerError>()
             where !er.IsWarning
             select er;
         mainError = source.FirstOrDefault<CompilerError>();
         mainErrors = (from er in source.Take<CompilerError>(5)
             where er.Line == mainError.Line
             select er).ToArray<CompilerError>();
         if (mainErrors.Length > 0)
         {
             if (selector == null)
             {
                 selector = er => this.GetErrorText(er);
             }
             string msg = string.Join("\r\n\r\n", mainErrors.Select<CompilerError, string>(selector).Distinct<string>().ToArray<string>());
             if (e.PartialSource)
             {
                 msg = "Cannot execute text selection: " + msg;
             }
             this.DisplayError(msg);
         }
         if (!this._modifiedWhenRunning)
         {
             foreach (CompilerError error in from ce in e.Errors.Cast<CompilerError>()
                 where ce.Line > 0
                 orderby ce.IsWarning
                 select ce)
             {
                 this.HighlightErrorOrWarning(error.Line - 1, error.Column - 1, error.ErrorText, error.IsWarning, true, error == mainError);
             }
             if (predicate == null)
             {
                 predicate = ce => (ce.Line == 0) && !mainErrors.Contains<CompilerError>(ce);
             }
             string message = string.Join("\n", (from ce in e.Errors.Cast<CompilerError>().Where<CompilerError>(predicate) select ce.ErrorText).ToArray<string>());
             if (message.Length > 0)
             {
                 this.HighlightErrorOrWarning(0, 0, message, true, true, false);
             }
         }
         if (mainError != null)
         {
             this.SetILContent("");
         }
         this._ilDirty = true;
         if (this.btnIL.Checked)
         {
             this.UpdateILContent();
         }
         if (mainError != null)
         {
             this.lblStatus.Text = "Error compiling query";
         }
         else if (this._compileOnly)
         {
             this.lblStatus.Text = "Query compiled " + (e.Errors.HasErrors ? "with warnings" : "successfully");
         }
         else
         {
             this.lblStatus.Text = "Executing";
         }
         if ((mainError != null) || this._compileOnly)
         {
             this.lblElapsed.Visible = false;
             if (!(((mainError == null) || this.AreResultsDetached()) || this.AreResultsCollapsed()))
             {
                 this.ToggleResultsCollapse();
             }
             this.EnableControls();
         }
         else
         {
             this.ShowResultsUponQueryStart();
         }
         if ((this._compileOnly && this._pendingReflection) && (mainError == null))
         {
             this.ReflectILNow();
         }
         this._pendingReflection = false;
         if ((mainError == null) && this._query.IsMyExtensions)
         {
             foreach (QueryControl control in MainForm.Instance.GetQueryControls())
             {
                 if ((control != this) && (control.Query.QueryKind != QueryLanguage.SQL))
                 {
                     control.CheckAutocompletionCache();
                 }
             }
         }
     }
 }