/// <summary> /// Get a copy of the documents container. /// </summary> private Documents _documentsCopy() { Documents docs = new Documents(); using (this.Lock.read()) { docs.AddRange(_documents); } return(docs); }
async Task StartDecompileAsync(MethodDef method) { bool canCompile = false, canceled = false; var assemblyReferences = Array.Empty <CompilerMetadataReference>(); string mainCode, hiddenCode; try { assemblyReferences = await DecompileAndGetRefsAsync(method); mainCode = decompileCodeState.MainOutput.ToString(); hiddenCode = decompileCodeState.HiddenOutput.ToString(); canCompile = true; } catch (OperationCanceledException) { canceled = true; mainCode = string.Empty; hiddenCode = string.Empty; } catch (Exception ex) { mainCode = ex.ToString(); hiddenCode = string.Empty; } const string MAIN_CODE_NAME = "main"; var codeDocs = Array.Empty <ICodeDocument>(); if (!canceled) { var docs = new List <IDecompiledDocument>(); docs.Add(new DecompiledDocument(mainCode, MAIN_CODE_NAME)); if (hiddenCode != string.Empty) { docs.Add(new DecompiledDocument(hiddenCode, MAIN_CODE_NAME + ".g")); } codeDocs = languageCompiler.AddDecompiledCode(new DecompiledCodeResult(docs.ToArray(), assemblyReferences, assemblyReferenceResolver, PlatformHelper.GetPlatform(method.Module))); } decompileCodeState?.Dispose(); decompileCodeState = null; Documents.AddRange(codeDocs); SelectedDocument = Documents.FirstOrDefault(a => a.NameNoExtension == MAIN_CODE_NAME) ?? Documents.FirstOrDefault(); foreach (var doc in Documents) { doc.TextView.MoveCaretTo(0, 0); doc.TextView.Selection.Clear(); } CanCompile = canCompile; HasDecompiled = true; OnPropertyChanged(nameof(HasDecompiled)); }
public async Task <bool> NextPageAsync() { Documents.Clear(); if (GetNextPageFunc == null) { Page = -1; return(false); } var results = await GetNextPageFunc(this).AnyContext(); Documents.AddRange(results.Documents); return(Documents.Count > 0); }
private void OnPerformSearch(object obj) { var items = new List <IDocumentHistoryItem>(_originalDocumentHistoryItems); if (!string.IsNullOrEmpty(SearchTerm)) { switch (SearchFilters.IndexOf(SelectedSearchFilter)) { case 0: case 5: items.Remove(item => item.RegistrationNumber == null || !item.RegistrationNumber.ToLower().Contains(SearchTerm.ToLower())); break; case 1: items.Remove(item => item.CustomerContact == null || !item.CustomerContact.ToLower().Contains(SearchTerm.ToLower())); break; case 2: items.Remove(item => item.TechnicianName == null || !item.TechnicianName.ToLower().Contains(SearchTerm.ToLower())); break; case 3: items.Remove(item => item.Office == null || !item.Office.ToLower().Contains(SearchTerm.ToLower())); break; case 4: items.Remove(item => item.DocumentType == null || !item.DocumentType.ToLower().Contains(SearchTerm.ToLower())); break; } } if (SelectedDocumentType != Resources.TXT_SELECT_ALL && SelectedDocumentType != Resources.TXT_ANALOGUE_ONLY) { items.Remove(item => item.Type != SelectedDocumentType); } if (SelectedDocumentType == Resources.TXT_ANALOGUE_ONLY) { items.Remove(item => item.Document == null || !(item.Document is TachographDocument) || ((TachographDocument)item.Document).IsDigital); } Documents.Clear(); Documents.AddRange(items); }
/// <summary> /// Includes documents for insert, updates or deletes. For deletes /// you can also use <see cref="Delete(string, string)"/>. /// </summary> /// <param name="docs"></param> /// <returns></returns> public virtual BulkRequest Include(params string[] docs) { Documents.AddRange(docs); return(this); }
async Task StartDecompileAsync(MethodDef method, MethodSourceStatement?methodSourceStatement) { bool canCompile = false, canceled = false; var assemblyReferences = Array.Empty <CompilerMetadataReference>(); string mainCode, hiddenCode; var refSpan = new Span(0, 0); try { assemblyReferences = await DecompileAndGetRefsAsync(method, methodSourceStatement); mainCode = decompileCodeState.MainOutput.ToString(); hiddenCode = decompileCodeState.HiddenOutput.ToString(); canCompile = true; var span = decompileCodeState.MainOutput.Span; if (span != null) { refSpan = span.Value; } } catch (OperationCanceledException) { canceled = true; mainCode = string.Empty; hiddenCode = string.Empty; } catch (Exception ex) { mainCode = ex.ToString(); hiddenCode = string.Empty; } const string MAIN_CODE_NAME = "main"; var codeDocs = Array.Empty <ICodeDocument>(); if (!canceled) { // This helps a little to speed up the code ProfileOptimizationHelper.StartProfile("add-decompiled-code-" + decompiler.UniqueGuid.ToString()); var docs = new List <IDecompiledDocument>(); docs.Add(new DecompiledDocument(mainCode, MAIN_CODE_NAME)); if (hiddenCode != string.Empty) { docs.Add(new DecompiledDocument(hiddenCode, MAIN_CODE_NAME + ".g")); } codeDocs = languageCompiler.AddDecompiledCode(new DecompiledCodeResult(docs.ToArray(), assemblyReferences, assemblyReferenceResolver, PlatformHelper.GetPlatform(method.Module))); } decompileCodeState?.Dispose(); decompileCodeState = null; foreach (var doc in codeDocs) { doc.TextView.Properties.AddProperty(editCodeTextViewKey, this); } Documents.AddRange(codeDocs.Select(a => new CodeDocument(a))); SelectedDocument = Documents.FirstOrDefault(a => a.NameNoExtension == MAIN_CODE_NAME) ?? Documents.FirstOrDefault(); foreach (var doc in Documents) { if (doc.NameNoExtension == MAIN_CODE_NAME && refSpan.End <= doc.TextView.TextSnapshot.Length) { doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, refSpan.Start)); } else { doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, 0)); } } CanCompile = canCompile; HasDecompiled = true; OnPropertyChanged(nameof(HasDecompiled)); }
async Task StartDecompileAsync() { bool canCompile = false, canceled = false; var assemblyReferences = Array.Empty <CompilerMetadataReference>(); SimpleDocument[] simpleDocuments = Array.Empty <SimpleDocument>(); try { var result = await DecompileAndGetRefsAsync(); assemblyReferences = result.Value; simpleDocuments = result.Key.Documents.ToArray(); canCompile = true; } catch (OperationCanceledException) { canceled = true; } catch (Exception ex) { simpleDocuments = new SimpleDocument[] { new SimpleDocument(MAIN_CODE_NAME, ex.ToString(), null) }; } var codeDocs = Array.Empty <ICodeDocument>(); if (!canceled) { // This helps a little to speed up the code ProfileOptimizationHelper.StartProfile("add-decompiled-code-" + decompiler.UniqueGuid.ToString()); var docs = new List <IDecompiledDocument>(); foreach (var simpleDoc in simpleDocuments) { docs.Add(new DecompiledDocument(simpleDoc.Text, simpleDoc.NameNoExtension)); } codeDocs = languageCompiler.AddDecompiledCode(new DecompiledCodeResult(docs.ToArray(), assemblyReferences, assemblyReferenceResolver, PlatformHelper.GetPlatform(sourceModule))); } decompileCodeState?.Dispose(); decompileCodeState = null; foreach (var doc in codeDocs) { doc.TextView.Properties.AddProperty(editCodeTextViewKey, this); } Documents.AddRange(codeDocs.Select(a => new CodeDocument(a))); SelectedDocument = Documents.FirstOrDefault(a => a.NameNoExtension == MAIN_CODE_NAME) ?? Documents.FirstOrDefault(); Debug.Assert(Documents.Count == simpleDocuments.Length); for (int i = 0; i < Documents.Count; i++) { var doc = Documents[i]; var caretSpan = simpleDocuments[i].CaretSpan; if (caretSpan != null && caretSpan.Value.End <= doc.TextView.TextSnapshot.Length) { doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, caretSpan.Value.Start)); } else { doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, 0)); } } CanCompile = canCompile; HasDecompiled = true; OnPropertyChanged(nameof(HasDecompiled)); }
public void AddDocuments(IEnumerable <Document> documents) { Documents.AddRange(documents); }