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 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; }
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); }
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 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); } }
public RepositoryDragData(LINQPad.Repository r) { this.Repository = r; }
public RepositoryDragData(LINQPad.Repository r, string dragText) : this(r) { this.DragText = dragText; }
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)); }
private bool ReadQuery(string data, string relativeBase) { this.ClearAutoSave(); this.FilePath = ""; this.Name = ""; this.FileWriteTimeUtc = null; this.Repository = null; this.IncludePredicateBuilder = false; this.ToDataGrids = false; this.Predefined = false; this.UISource = null; this.IsModified = false; this._requiresRecompilation = true; this.AdditionalReferences = new string[0]; this.AdditionalGACReferences = new string[0]; this.AdditionalNamespaces = new string[0]; if (!_validQueryHeader.IsMatch(data)) { this.Source = data; this.IsModified = false; return(false); } XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None); Stream xmlFragment = new MemoryStream(Encoding.UTF8.GetBytes(data)); XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Element, context); reader.MoveToContent(); XmlReader reader2 = reader.ReadSubtree(); StringBuilder output = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(output)) { writer.WriteNode(reader2, true); } XElement element = XElement.Parse(output.ToString()); int lineNumber = reader.LineNumber; if (element.Attribute("Kind") != null) { try { this.QueryKind = (QueryLanguage)Enum.Parse(typeof(QueryLanguage), (string)element.Attribute("Kind"), true); } catch (ArgumentException) { } } XElement store = element.Element("Connection"); if (store != null) { LINQPad.Repository repository = new LINQPad.Repository(store) { Persist = false }; this.Repository = repository; } this.AdditionalReferences = (from refElement in element.Elements("Reference") select ResolveFileReference(relativeBase, refElement) into refPath where refPath != null select refPath).ToArray <string>(); this.AdditionalGACReferences = (from refElement in element.Elements("GACReference") select(string) refElement).ToArray <string>(); this.AdditionalNamespaces = (from nsElement in element.Elements("Namespace") select(string) nsElement).ToArray <string>(); if (((bool?)element.Element("IncludePredicateBuilder")) == true) { this.IncludePredicateBuilder = true; } if ((element.Element("Output") != null) && (element.Element("Output").Value == "DataGrids")) { this.ToDataGrids = true; } StringReader reader3 = new StringReader(data); for (int i = 0; i < lineNumber; i++) { reader3.ReadLine(); } this.Source = reader3.ReadToEnd().Trim(); this.IsModified = false; return(true); }
private bool ReadQuery(string data, string relativeBase) { this.ClearAutoSave(); this.FilePath = ""; this.Name = ""; this.FileWriteTimeUtc = null; this.Repository = null; this.IncludePredicateBuilder = false; this.ToDataGrids = false; this.Predefined = false; this.UISource = null; this.IsModified = false; this._requiresRecompilation = true; this.AdditionalReferences = new string[0]; this.AdditionalGACReferences = new string[0]; this.AdditionalNamespaces = new string[0]; if (!_validQueryHeader.IsMatch(data)) { this.Source = data; this.IsModified = false; return false; } XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None); Stream xmlFragment = new MemoryStream(Encoding.UTF8.GetBytes(data)); XmlTextReader reader = new XmlTextReader(xmlFragment, XmlNodeType.Element, context); reader.MoveToContent(); XmlReader reader2 = reader.ReadSubtree(); StringBuilder output = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(output)) { writer.WriteNode(reader2, true); } XElement element = XElement.Parse(output.ToString()); int lineNumber = reader.LineNumber; if (element.Attribute("Kind") != null) { try { this.QueryKind = (QueryLanguage) Enum.Parse(typeof(QueryLanguage), (string) element.Attribute("Kind"), true); } catch (ArgumentException) { } } XElement store = element.Element("Connection"); if (store != null) { LINQPad.Repository repository = new LINQPad.Repository(store) { Persist = false }; this.Repository = repository; } this.AdditionalReferences = (from refElement in element.Elements("Reference") select ResolveFileReference(relativeBase, refElement) into refPath where refPath != null select refPath).ToArray<string>(); this.AdditionalGACReferences = (from refElement in element.Elements("GACReference") select (string) refElement).ToArray<string>(); this.AdditionalNamespaces = (from nsElement in element.Elements("Namespace") select (string) nsElement).ToArray<string>(); if (((bool?) element.Element("IncludePredicateBuilder")) == true) { this.IncludePredicateBuilder = true; } if ((element.Element("Output") != null) && (element.Element("Output").Value == "DataGrids")) { this.ToDataGrids = true; } StringReader reader3 = new StringReader(data); for (int i = 0; i < lineNumber; i++) { reader3.ReadLine(); } this.Source = reader3.ReadToEnd().Trim(); this.IsModified = false; return true; }