public Hyperlinq(LINQPad.QueryLanguage queryLanguage, string query, string text) { this.QueryLanguage = queryLanguage; this.Query = query; this.Text = text; this.Uri = ""; }
public DataContextInfo(LINQPad.Repository repository, bool busy, string status, string error, TempFileRef assemblyPath, IEnumerable<ExplorerItem> schema) { this.Repository = repository; this.Busy = busy; this.Status = status; this.Error = error; this.AssemblyPath = assemblyPath; this.Schema = schema; }
private DataContextManager(LINQPad.Repository r, DataContextCallback subscription) { this.Repository = r; this._subscription = subscription; lock (_runners) { if (_runners.TryGetValue(r, out this._runner)) { this._runner.RefCount++; } else { _runners[this.Repository] = this._runner = new Runner(this.Repository); } } if (this._subscription != null) { this._runner.DataContextChanged += this._subscription; } }
public RepositoryNode(LINQPad.Repository r) : base(r.GetFriendlyName()) { EventHandler handler = null; this._locker = new object(); Timer timer = new Timer { Interval = 0xea60 }; this._resourcesTimer = timer; this.Repository = r; base.NodeFont = SchemaTree.BaseFont; base.ImageKey = base.SelectedImageKey = this.NormalImageKey; this.BaseText = base.Text; handler = delegate (object sender, EventArgs e) { if (base.IsExpanded || this.Populating) { this._resourcesTimer.Stop(); } else { this.OnIdle(); } }; this._resourcesTimer.Tick += handler; }
public RepositoryDragData(LINQPad.Repository r) { this.Repository = r; }
public LazyQueryLoader(LINQPad.ObjectModel.Query q) { this.Query = q; }
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(); }
public RepositoryDragData(LINQPad.Repository r, string dragText) : this(r) { this.DragText = dragText; }
private static string GetItemText(LINQPad.Extensibility.DataContext.ExplorerItem item, bool sqlMode) { if (!(sqlMode && !string.IsNullOrEmpty(item.SqlName))) { return item.Text; } string sqlName = item.SqlName; if (!string.IsNullOrEmpty(item.SqlTypeDeclaration)) { sqlName = sqlName + " (" + item.SqlTypeDeclaration + ")"; } return sqlName; }
public QueryRunner(LINQPad.ExecutionModel.Server server) { this.Server = server; }
public QueryMatch(LINQPad.ObjectModel.Query query) : base(new string[] { query.Name, query.Location }) { this.Query = query; }
public ExplorerItemNode(Repository r, LINQPad.Extensibility.DataContext.ExplorerItem m) : base(GetItemText(m, UseSqlMode(r))) { this._repository = r; this._explorerItem = m; this._sqlMode = UseSqlMode(r); base.ImageKey = base.SelectedImageKey = m.Icon.ToString(); base.ToolTipText = m.ToolTipText; if (m.HyperlinkTarget != null) { base.NodeFont = SchemaTree.UnderlineFont; } else if (m.Kind == ExplorerItemKind.Parameter) { base.NodeFont = SchemaTree.ItalicFont; } else if (m.Kind != ExplorerItemKind.QueryableObject) { base.NodeFont = SchemaTree.BaseFont; } if (m.Kind == ExplorerItemKind.Category) { base.ForeColor = (SystemColors.Window.GetBrightness() < 0.5f) ? Color.FromArgb(120, 0xff, 0xff) : Color.FromArgb(0, 120, 120); } else if (m.Kind == ExplorerItemKind.CollectionLink) { base.ForeColor = (SystemColors.Window.GetBrightness() < 0.5f) ? Color.LightGreen : Color.Green; } else if (m.Kind == ExplorerItemKind.Parameter) { base.ForeColor = (SystemColors.Window.GetBrightness() < 0.5f) ? Color.FromArgb(110, 140, 0xff) : Color.FromArgb(60, 80, 150); } else if (m.Kind == ExplorerItemKind.Property) { if (SystemColors.Window.GetBrightness() > 0.8f) { base.ForeColor = Color.FromArgb(40, 40, 40); } } else if (m.Kind == ExplorerItemKind.ReferenceLink) { base.ForeColor = (SystemColors.Window.GetBrightness() < 0.5f) ? Color.RoyalBlue : Color.Blue; } else if (m.Kind == ExplorerItemKind.Schema) { base.ForeColor = (SystemColors.Window.GetBrightness() < 0.5f) ? Color.Orchid : Color.Purple; } if (m.Icon == ExplorerIcon.Inherited) { base.ForeColor = Color.FromArgb(base.ForeColor.R + ((0xff - base.ForeColor.R) / 3), base.ForeColor.G + ((0xff - base.ForeColor.G) / 3), base.ForeColor.B + ((0xff - base.ForeColor.B) / 3)); } bool flag = m.Kind == ExplorerItemKind.QueryableObject; if (m.Children != null) { foreach (LINQPad.Extensibility.DataContext.ExplorerItem item in m.Children) { if (flag) { this._dormantChildren = true; } else { base.Nodes.Add(new ExplorerItemNode(this._repository, item)); } } } if (this._dormantChildren) { base.Nodes.Add(" "); } }
public void ExecuteClrQuery(Client client, LINQPad.Repository r, string assemblyPath, int lineOffset, string[] additionalRefs, bool mta, bool compilationHadWarnings, string queryPath, string queryName, LINQPad.UI.PluginWindowManager pluginWinManager, bool executionTrackingEnabled) { this.IsClrQuery = true; this._client = client; _currentServer = null; this._repository = r; this._assemblyPath = assemblyPath; this._lineOffset = lineOffset; this._additionalRefs = additionalRefs; this._compilationHadWarnings = compilationHadWarnings; this._lastLambdaLength = 0; this._lastSqlLogLength = 0; this._lastResultsLength = 0; this._cacheVersionAtStart = UserCache.CacheVersion; this.PluginWindowManager = pluginWinManager; CurrentQueryAdditionalRefs = this._additionalRefs; Util.Progress = null; Util.CurrentQueryPath = (queryPath == "") ? null : queryPath; Util.CurrentQueryName = queryName; PluginServer.CustomCount = 1; UserCache.ClearSession(); Thread thread = new Thread(() => this.StartQuery(new ClrQueryRunner(this, executionTrackingEnabled))) { IsBackground = true, Name = System.AppDomain.CurrentDomain.FriendlyName }; this._worker = thread; if (!mta) { this._worker.SetApartmentState(ApartmentState.STA); } this._worker.Start(); }
public void InstallDbProviders(LINQPad.Repository r) { if (!_linqPadDbProvidersInstalled) { LINQPadDbController.InstallCustomProviders(); _linqPadDbProvidersInstalled = true; if ((r != null) && (r.DriverLoader.InternalID == "EntityFrameworkDbContext")) { try { EntityFrameworkDbContextDriver.PatchCxFactory(r); } catch { } } } }
public static void GetDataContextInfo(LINQPad.Repository r, DataContextCallback callback, SchemaChangeTestMode schemaTestMode) { DataContextManager manager = new DataContextManager(r, null); DataContextCallback callback2 = delegate (DataContextInfo info) { manager.Dispose(); if (callback != null) { callback(info); } }; if (!((callback != null) || manager.HasOtherSubscribers)) { manager.Dispose(); } else { manager.GetDataContextInfo(callback2, schemaTestMode); } }
internal Runner(LINQPad.Repository r) { this._repository = r; this._lastUsed = DateTime.UtcNow; }
public static DataContextManager SubscribeToDataContextChanges(LINQPad.Repository r, DataContextCallback subscription) { return new DataContextManager(r, subscription); }
public static void RefreshIfInUse(LINQPad.Repository r) { lock (_runners) { Runner runner; if (!_runners.TryGetValue(r, out runner)) { return; } if (runner.RefCount <= 0) { _runners.Remove(runner.Repository); runner.Dispose(); return; } } RefreshDataContextInfo(r, SchemaChangeTestMode.ForceRefresh); }
public static void RefreshDataContextInfo(LINQPad.Repository r, SchemaChangeTestMode schemaTestMode) { if (schemaTestMode == SchemaChangeTestMode.None) { throw new ArgumentException("schemaTestMode cannot be None when calling RefreshDataContextInfo"); } GetDataContextInfo(r, null, schemaTestMode); }
public void ExecuteSqlQuery(QueryLanguage language, LINQPad.Repository repository, string query, string[] refs, Client client, LINQPad.UI.PluginWindowManager pluginWinManager) { QueryRunner runner; this.IsClrQuery = false; Util.Progress = null; this._repository = repository; this._sqlQuery = query; this._client = client; this._additionalRefs = refs; CurrentQueryAdditionalRefs = this._additionalRefs; this.PluginWindowManager = pluginWinManager; if (language == QueryLanguage.ESQL) { runner = new ESqlQueryRunner(this, query); } else { runner = new SqlQueryRunner(this, query); } Thread thread = new Thread(() => this.StartQuery(runner)) { Name = ((language == QueryLanguage.ESQL) ? "E" : "") + "SQL Query Runner", IsBackground = true }; this._worker = thread; this._worker.SetApartmentState(ApartmentState.STA); this._worker.Start(); }
public QueryControlToStringWrapper(LINQPad.UI.QueryControl qc) { this.QueryControl = qc; }
public static IDbConnection OpenCachedCx(LINQPad.Repository r) { lock (_cachedCxLock) { if (_cachedCx != null) { bool flag2 = (_cachedRepos == null) || !_cachedRepos.IsEquivalent(r); if (!((_cachedCx.State != ConnectionState.Open) || flag2)) { return _cachedCx; } if ((_cachedCx.State != ConnectionState.Closed) || flag2) { try { _cachedCx.Dispose(); } catch { } _cachedCx = null; } } if (_cachedCx == null) { _cachedCx = r.Open(true); _cachedRepos = r; } else { _cachedCx.Open(); } return _cachedCx; } }
public Hyperlinq(LINQPad.QueryLanguage queryLanguage, string query) : this(queryLanguage, query, query) { }