private void OnNewDatabaseAvailable(object sender, EventArgs e) { _typeDb = _factory.GetCurrentDatabase(); if (_references != null) { _typeDb = _typeDb.Clone(); foreach (var reference in _references) { string modName; try { modName = Path.GetFileNameWithoutExtension(reference.Name); } catch (Exception) { continue; } _typeDb.LoadExtensionModuleAsync(modName, reference.Name).Wait(); } } var evt = ModuleNamesChanged; if (evt != null) { evt(this, EventArgs.Empty); } }
private async void OnNewDatabaseAvailable(object sender, EventArgs e) { var factory = _factory; if (factory == null) { // We have been disposed already, so ignore this event return; } _typeDb = factory.GetCurrentDatabase(); List<ProjectReference> references = null; lock (_referencesLock) { references = _references != null ? _references.ToList() : null; } if (references != null) { _typeDb = _typeDb.Clone(); foreach (var reference in references) { string modName; try { modName = Path.GetFileNameWithoutExtension(reference.Name); } catch (ArgumentException) { continue; } try { await _typeDb.LoadExtensionModuleAsync(modName, reference.Name); } catch (Exception ex) { try { Directory.CreateDirectory(factory.DatabasePath); } catch (IOException) { } catch (UnauthorizedAccessException) { } if (Directory.Exists(factory.DatabasePath)) { var analysisLog = Path.Combine(factory.DatabasePath, "AnalysisLog.txt"); for (int retries = 10; retries > 0; --retries) { try { File.AppendAllText(analysisLog, string.Format( "Exception while loading extension module {0}{1}{2}{1}", reference.Name, Environment.NewLine, ex )); break; } catch (Exception ex2) { if (ex2.IsCriticalException()) { throw; } } } } } } } var evt = ModuleNamesChanged; if (evt != null) { evt(this, EventArgs.Empty); } }
public Task AddReferenceAsync(ProjectReference reference, CancellationToken cancellationToken = default(CancellationToken)) { if (reference == null) { return(MakeExceptionTask(new ArgumentNullException("reference"))); } bool cloneDb = false; lock (_referencesLock) { if (_references == null) { _references = new HashSet <ProjectReference>(); cloneDb = true; } } if (cloneDb && _typeDb != null) { // If we needed to set _references, then we also need to clone // _typeDb to avoid adding modules to the shared database. _typeDb = _typeDb.Clone(); } switch (reference.Kind) { case ProjectReferenceKind.ExtensionModule: lock (_referencesLock) { _references.Add(reference); } string filename; try { filename = Path.GetFileNameWithoutExtension(reference.Name); } catch (Exception e) { return(MakeExceptionTask(e)); } if (_typeDb != null) { return(_typeDb.LoadExtensionModuleAsync(filename, reference.Name, cancellationToken).ContinueWith(RaiseModulesChanged)); } break; } return(Task.Factory.StartNew(EmptyTask)); }
private void OnNewDatabaseAvailable(object sender, EventArgs e) { _typeDb = _factory.GetCurrentDatabase(); if (_references != null) { _typeDb = _typeDb.Clone(); foreach (var reference in _references) { string modName; try { modName = Path.GetFileNameWithoutExtension(reference.Name); } catch (Exception) { continue; } _typeDb.LoadExtensionModuleAsync(modName, reference.Name).Wait(); } } var evt = ModuleNamesChanged; if (evt != null) { evt(this, EventArgs.Empty); } }
private async void OnNewDatabaseAvailable(object sender, EventArgs e) { var factory = _factory; if (factory == null) { // We have been disposed already, so ignore this event return; } _typeDb = factory.GetCurrentDatabase(); List <ProjectReference> references = null; lock (_referencesLock) { references = _references != null?_references.ToList() : null; } if (references != null) { _typeDb = _typeDb.Clone(); foreach (var reference in references) { string modName; try { modName = Path.GetFileNameWithoutExtension(reference.Name); } catch (ArgumentException) { continue; } try { await _typeDb.LoadExtensionModuleAsync(modName, reference.Name); } catch (Exception ex) { try { Directory.CreateDirectory(factory.DatabasePath); } catch (IOException) { } catch (UnauthorizedAccessException) { } if (Directory.Exists(factory.DatabasePath)) { var analysisLog = Path.Combine(factory.DatabasePath, "AnalysisLog.txt"); for (int retries = 10; retries > 0; --retries) { try { File.AppendAllText(analysisLog, string.Format( "Exception while loading extension module {0}{1}{2}{1}", reference.Name, Environment.NewLine, ex )); break; } catch (Exception ex2) { if (ex2.IsCriticalException()) { throw; } } } } } } } var evt = ModuleNamesChanged; if (evt != null) { evt(this, EventArgs.Empty); } }