private void DataContextInfoUpdated(DataContextInfo m)
 {
     if (this._dcManager != null)
     {
         this.UpdateNode(m);
     }
 }
示例#2
0
 private void UpdateDC(DataContextInfo dc)
 {
     try
     {
         this._typeResolver.set_CurrentDCAssemblyPath((dc.AssemblyPath == null) ? null : dc.AssemblyPath.FullPath);
         this._typeResolver.set_CurrentDCError(dc.Error);
         this._query.PolluteCachedDomain(false);
         this._typeResolver.set_CurrentDCNamespace(this._query.QueryBaseClassNamespace);
         this._typeResolver.set_CurrentDCTypeName(this._query.QueryBaseClassName);
         this.ConfigureLanguage();
         this.ConfigureResolver();
     }
     catch (Exception exception)
     {
         Program.ProcessException(exception);
     }
 }
示例#3
0
        private void DataContextInfoUpdated(DataContextInfo m)
        {
            // This item is obfuscated and can not be translated.
            if ((this._dcManager == null) || (m.Repository != this._dcManager.Repository))
            {
                return;
            }
Label_0051:
            if (this._hostControl != null)
            {
            }
            if (0 == 0)
            {
                if (this._hostControl != null)
                {
                    this._hostControl.BeginInvoke(new DataContextCallback(this.UpdateDC), new object[] { m });
                }
            }
            else if (!this._hostControl.IsDisposed)
            {
                Thread.Sleep(100);
                goto Label_0051;
            }
        }
示例#4
0
 private void CompileAndRun(DataContextInfo dcInfo)
 {
     try
     {
         object obj2;
         QueryCore core;
         lock ((obj2 = this._locker))
         {
             core = this._query;
             if ((core == null) || this._cancelRequest)
             {
                 return;
             }
         }
         if ((dcInfo != null) && (dcInfo.Error != null))
         {
             this.OnQueryCompleted("Connection error", dcInfo.Error);
         }
         else
         {
             DataContextDriver driver = core.GetDriver(true);
             if ((driver != null) && (driver.AssembliesToAddError != null))
             {
                 this.OnQueryCompleted("Error loading custom driver assemblies", driver.AssembliesToAddError.Message);
             }
             else
             {
                 QueryCompiler c = null;
                 if (((this._lastCompilation != null) && (this._lastCompilation.AssemblyDLL != null)) && File.Exists(this._lastCompilation.AssemblyDLL.FullPath))
                 {
                     c = this._lastCompilation.Compiler;
                     if (!((((dcInfo != null) || (this._lastCompilation.DataContextDLL == null)) && ((dcInfo == null) || (this._lastCompilation.DataContextDLL != null))) ? (((dcInfo == null) || (this._lastCompilation.DataContextDLL == null)) || (dcInfo.AssemblyPath == this._lastCompilation.DataContextDLL)) : false))
                     {
                         c = null;
                     }
                 }
                 bool flag2 = false;
                 if (c == null)
                 {
                     this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Compiling;
                     c = QueryCompiler.Create(core, true);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                     }
                     c.Compile(this._source, core, (dcInfo == null) ? null : dcInfo.AssemblyPath);
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (c.Errors.HasErrors)
                         {
                             this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                             this.QueryCompleted = null;
                             this.PluginsReady = null;
                             this.CustomClickComplete = null;
                         }
                     }
                     this.OnQueryCompiled(new QueryCompilationEventArgs(c, (dcInfo == null) ? null : dcInfo.AssemblyPath, this._partialSource));
                     flag2 = true;
                 }
                 lock ((obj2 = this._locker))
                 {
                     if ((this._cancelRequest || c.Errors.HasErrors) || this._compileOnly)
                     {
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Finished;
                         return;
                     }
                 }
                 Server server = this._serverGenerator(this);
                 if (server != null)
                 {
                     lock ((obj2 = this._locker))
                     {
                         if (this._cancelRequest)
                         {
                             return;
                         }
                         if (this._server != server)
                         {
                             this.ClearServer();
                         }
                         this._server = server;
                         this._executionProgress = LINQPad.ExecutionModel.ExecutionProgress.Executing;
                     }
                     bool flag7 = c.References.Any<string>(r => r.EndsWith(".winmd", StringComparison.InvariantCultureIgnoreCase));
                     server.WriteResultsToGrids = core.ToDataGrids;
                     server.ExecuteClrQuery(this, core.Repository, c.OutputFile.FullPath, c.LineOffset, c.References.ToArray<string>(), Program.MTAMode || flag7, flag2 && c.Errors.HasWarnings, core.FilePath, core.Name, this._pluginWinManager, !UserOptionsLive.Instance.ExecutionTrackingDisabled);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         try
         {
             this.OnQueryCompleted("Unable to execute query", "");
         }
         catch
         {
         }
         Program.ProcessException(exception);
     }
 }
示例#5
0
 private void GotDataContext(DataContextInfo dcInfo)
 {
     lock (this._locker)
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     new Thread(() => this.CompileAndRun(dcInfo)) { Name = "DataContext Query Compiler", IsBackground = true }.Start();
 }
 private void UpdateDC(DataContextInfo dc)
 {
     try
     {
         this._typeResolver.set_CurrentDCAssemblyPath((dc.AssemblyPath == null) ? null : dc.AssemblyPath.FullPath);
         this._typeResolver.set_CurrentDCError(dc.Error);
         this._query.PolluteCachedDomain(false);
         this._typeResolver.set_CurrentDCNamespace(this._query.QueryBaseClassNamespace);
         this._typeResolver.set_CurrentDCTypeName(this._query.QueryBaseClassName);
         this.ConfigureLanguage();
         this.ConfigureResolver();
     }
     catch (Exception exception)
     {
         Program.ProcessException(exception);
     }
 }
 private void DataContextInfoUpdated(DataContextInfo m)
 {
     // This item is obfuscated and can not be translated.
     if ((this._dcManager == null) || (m.Repository != this._dcManager.Repository))
     {
         return;
     }
 Label_0051:
     if (this._hostControl != null)
     {
     }
     if (0 == 0)
     {
         if (this._hostControl != null)
         {
             this._hostControl.BeginInvoke(new DataContextCallback(this.UpdateDC), new object[] { m });
         }
     }
     else if (!this._hostControl.IsDisposed)
     {
         Thread.Sleep(100);
         goto Label_0051;
     }
 }
            private void GetDCInfo(SchemaChangeTestMode schemaTestMode)
            {
                Exception exception;
                bool      flag = true;

                try
                {
                    object obj2;
                    try
                    {
                        bool flag2;
                        if (this._disposed)
                        {
                            return;
                        }
                        if (!((flag2 = (this._schema == null) || (schemaTestMode == SchemaChangeTestMode.ForceRefresh)) || (schemaTestMode == SchemaChangeTestMode.None)))
                        {
                            bool?nullable = this.HasSchemaChanged();
                            flag2 = nullable.HasValue ? nullable.GetValueOrDefault() : (schemaTestMode == SchemaChangeTestMode.TestAndFailPositive);
                        }
                        if (flag2)
                        {
                            this.UpdateSchema();
                        }
                        else
                        {
                            flag = false;
                        }
                        if (this._lastSchemaChange == new DateTime())
                        {
                            this.HasSchemaChanged();
                        }
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        if (!(!this._repository.DriverLoader.IsInternalAuthor || IsUserError(exception)))
                        {
                            Program.ProcessException(exception);
                        }
                        else
                        {
                            Log.Write(exception, "Error opening DataContext");
                        }
                        lock ((obj2 = this._locker))
                        {
                            if (this._worker == Thread.CurrentThread)
                            {
                                this._error = (exception is AccessViolationException) ? "An AccessViolationException was thrown when trying to open the connection." : exception.Message;
                                this._repository.IsAutoGenAssemblyAvailable = false;
                                this._repository.AutoGenAssemblyFailed      = true;
                            }
                        }
                    }
                    Delegate[]      invocationList = null;
                    Delegate[]      delegateArray2 = null;
                    DataContextInfo dCInfo         = null;
                    lock ((obj2 = this._locker))
                    {
                        if (this._worker != Thread.CurrentThread)
                        {
                            return;
                        }
                        this._status = "";
                        this._busy   = false;
                        dCInfo       = this.GetDCInfo();
                        if (flag && (this._changeSubscribers != null))
                        {
                            invocationList = this._changeSubscribers.GetInvocationList();
                            foreach (DataContextCallback callback in this._changeSubscribers.GetInvocationList())
                            {
                                if (this._oneOffSubscribers == null)
                                {
                                    break;
                                }
                                this._oneOffSubscribers = (DataContextCallback)Delegate.Remove(this._oneOffSubscribers, callback);
                            }
                        }
                        if (this._oneOffSubscribers != null)
                        {
                            delegateArray2 = this._oneOffSubscribers.GetInvocationList();
                        }
                        this._oneOffSubscribers = null;
                    }
                    if (invocationList != null)
                    {
                        foreach (DataContextCallback callback2 in invocationList)
                        {
                            callback2(dCInfo);
                        }
                    }
                    if (delegateArray2 != null)
                    {
                        foreach (DataContextCallback callback2 in delegateArray2)
                        {
                            callback2(dCInfo);
                        }
                    }
                    if (dCInfo.Error != null)
                    {
                        DataContextManager._globalErrorHandlers(dCInfo);
                    }
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                    Program.ProcessException(exception);
                }
            }
 private void UpdateNode(DataContextInfo m)
 {
     TreeNode[] nodes;
     this._error = false;
     if (m.Busy)
     {
         if (((base.TreeView != null) && !base.TreeView.IsDisposed) && base.TreeView.IsHandleCreated)
         {
             base.SetStatusInvoke(m.Status);
         }
     }
     else
     {
         this._error = m.Error != null;
         if (this._error)
         {
             if (!((base.TreeView == null) || base.TreeView.IsDisposed))
             {
                 base.WaitForTreeView();
                 base.TreeView.Invoke(new Action<string>(this.SetError), new object[] { m.Error });
             }
         }
         else
         {
             if (((base.TreeView != null) && !base.TreeView.IsDisposed) && base.TreeView.IsHandleCreated)
             {
                 base.SetStatusInvoke("");
             }
             if ((m.Schema != null) && (m.Schema.GetHashCode() != this._lastSchemaHash))
             {
                 this._lastSchemaHash = m.Schema.GetHashCode();
                 this._dormantNodes = null;
                 nodes = base.ToExplorerItemNodes(m.Schema);
                 if ((base.TreeView != null) && !base.TreeView.IsDisposed)
                 {
                     base.WaitForTreeView();
                     base.TreeView.Invoke(() => this.AddNodes(nodes));
                     base.TreeView.Invoke(new Action(this.SetDone));
                 }
             }
         }
     }
 }
示例#10
0
 private void DataContextGenerationError(DataContextInfo dcInfo)
 {
     base.BeginInvoke(delegate {
         RepositoryNode node = this.GetAllRepositoryNodes(true).FirstOrDefault<RepositoryNode>(db => db.Repository == dcInfo.Repository);
         if (node != null)
         {
             node.ShowErrorIfUninitialized(dcInfo.Error);
         }
     });
 }