private void HighlightUsages_CheckedChanged(object sender, EventArgs e) { WordHelpers.RunActionWithWaitCursor(() => { ResetTheCounters(); var isFieldChecked = HighlightAllUsages.Checked; if (isFieldChecked) { if (_corectDefinitionOccurences.Count != 0) { HighLightCorrectUsages(); NextDefinition.Enabled = true; } else { if (HighlightIncorrectUsages.Checked && _incorrectDefinitionOccurences.Count != 0) { NextDefinition.Enabled = true; } } return; } if (!HighlightIncorrectUsages.Checked) { NextDefinition.Enabled = false; PreviousDefiniton.Enabled = false; } DocumentHelpers.ClearHightlightOnAllInstancesOfTerm(_corectDefinitionOccurences); }); }
private void GetPropertiesAndWriteCsvHeader(RavenJObject result, out bool includeId) { includeId = false; properties = DocumentHelpers.GetPropertiesFromJObject(result, parentPropertyPath: "", includeNestedProperties: true, includeMetadata: false, excludeParentPropertyNames: true).ToList(); RavenJToken token; if (result.TryGetValue("@metadata", out token)) { var metadata = token as RavenJObject; if (metadata != null) { if (metadata.TryGetValue("@id", out token)) { OutputCsvValue("@id"); writer.Write(','); includeId = true; } } } foreach (var property in properties) { OutputCsvValue(property); writer.Write(','); } writer.WriteLine(); }
internal static async Task BuildMultiple( StreamWriter writer, Assembly assembly, Type type, List <MethodInfo> methods, XDocument xmlComments) { await DocumentHelpers.PageTitle( writer, async w => { await TypeHelper.FullName(w, type, t => t.Name, "<", ">"); await w.WriteAsync("."); await MethodHelper.MethodName(w, methods.First(), t => t.Name, "<", ">"); }, "Methods"); await DocumentHelpers.PageHeader(writer, type, xmlComments); await MethodDocument.Overloads(writer, methods, xmlComments); foreach (var method in methods) { await writer.WriteAsync("## "); await MethodHelper.MethodName(writer, methods.First(), t => t.Name, "<", ">"); await MethodHelper.MethodParameterTypes(writer, method, t => t.Name, "<", ">"); await writer.WriteLineAsync(); await MethodDocument.MethodDetails(writer, assembly, type, method, xmlComments); } }
public static oval_results CreateFromDocuments( Definitions.oval_definitions definitions, oval_system_characteristics systemcharacteristics, oval_variables evaluatedExternalVariables) { oval_results newResult = new oval_results(); newResult.generator = DocumentHelpers.GetDefaultGenerator(); newResult.oval_definitions = definitions; newResult.results = new List <SystemType> { new SystemType() }; newResult.results[0].oval_system_characteristics = systemcharacteristics; newResult.EvaluatedExternalVariables = evaluatedExternalVariables; // Generate new Definition Result entries foreach (var definition in definitions.definitions) { if ((definition.criteria == null) || (definition.criteria.Items == null) || (definition.criteria.Items.Count() < 1)) { continue; } var newDefinitionResult = new DefinitionType(definition); newResult.results[0].definitions.Add(newDefinitionResult); } // Generate new Test Result entries foreach (var test in definitions.tests) { var newTestResult = new TestType(test); newResult.results[0].tests.Add(newTestResult); } return(newResult); }
public override void Redo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); SaveNote(note); DocumentHelpers.DeleteRow(note, treeListView); }
public void List_of_Siblings() { foreach (var item in DocumentHelpers.Siblings(@"c:\\temp\\test\\a.cshtml")) { Console.WriteLine(item); } }
public async Task UpdateRangeUpdatesEntities() { // Arrange var id = Guid.NewGuid().ToString(); var addedDummy = new Dummy { Id = id, Name = "Test" }; addedDummy.ValidateEntityForCosmosDb(); var documentId = addedDummy.GetDocumentId(); var document = addedDummy.GetCosmosDbFriendlyEntity(); JsonReader reader = new JTokenReader(document); var actualDocument = new Document(); actualDocument.LoadFrom(reader); JToken jtoken = JToken.FromObject(document); _mockDocumentClient.Setup(x => x.ReplaceDocumentAsync(DocumentHelpers.GetDocumentSelfLink("databaseName", It.IsAny <string>(), documentId), jtoken, It.IsAny <RequestOptions>())).ReturnsAsync(new ResourceResponse <Document>(actualDocument)); var entityStore = new CosmosStore <Dummy>(_mockDocumentClient.Object, "databaseName", new CosmosDatabaseCreator(_mockDocumentClient.Object), new CosmosCollectionCreator(_mockDocumentClient.Object)); addedDummy.Name = "newTest"; // Act var result = await entityStore.UpdateRangeAsync(addedDummy); // Assert Assert.Empty(result.FailedEntities); }
private void DefinitionBox_FormClosing(object sender, FormClosingEventArgs e) { ThisAddIn.DecreaseDialogCoords(); WordHelpers.RunActionWithWaitCursor(() => { if (HighlightAllUsages.Checked) { if (_corectDefinitionOccurences.Count != 0) { DocumentHelpers.ClearHightlightOnAllInstancesOfTerm(_corectDefinitionOccurences); } } if (HighlightIncorrectUsages.Checked) { if (_incorrectDefinitionOccurences.Count != 0) { DocumentHelpers.ClearHightlightOnAllInstancesOfTerm(_incorrectDefinitionOccurences); } } if (_currentPosition != null) { Navigate.ToRange(_currentPosition); } }); }
private static void SetPartitionKeyAsIdIfCollectionIsShared(bool isSharedCollection, DocumentCollection collection) { if (isSharedCollection) { collection.PartitionKey = DocumentHelpers.GetPartitionKeyDefinition(CosmosConstants.CosmosId); } }
internal static async Task Build(StreamWriter writer, Type type, XDocument xmlComments) { await DocumentHelpers.PageTitle( writer, async w => await TypeHelper.FullName(w, type, t => t.Name, "<", ">"), TypeHelper.TypeTypeTitle(type)); await DocumentHelpers.PageHeader(writer, type, xmlComments); await writer.WriteLineAsync(XmlCommentHelper.Summary(XmlCommentHelper.TypeElement(xmlComments, type))); await writer.WriteLineAsync(); await TypeDocument.Signature(writer, type); await TypeDocument.TypeParameters(writer, type, xmlComments); await TypeDocument.Inheritance(writer, type); await TypeDocument.Implements(writer, type); // TODO - Derived // TODO - Attributes await TypeDocument.Constructors(writer, type, xmlComments); await TypeDocument.Properties(writer, type, xmlComments); await TypeDocument.Methods(writer, type, xmlComments); // TODO - Operators // TODO - Explicit Interface Implementations // TODO - Extension Methods }
public static void InsertItemInItemsControl(ItemsControl itemsControl, OutlinerNote itemToInsert, int insertionIndex) { OutlinerNote parent = itemsControl.DataContext as OutlinerNote; if (parent == null) { parent = (itemToInsert as OutlinerNote).GetRoot(); } OutlinerNote newNote = new OutlinerNote(parent); newNote.Clone(itemToInsert); Window ownerWindow = TreeListView.FindParentWindow(itemsControl); if (ownerWindow == null) { throw new Exception("Window cannot be null"); } DocumentHelpers.CopyNodesRecursively(newNote, itemToInsert); parent.SubNotes.Insert(insertionIndex, newNote); if (itemsControl is TreeListView) { ((TreeListView)itemsControl).MakeActive(newNote, -1, false); } }
/// <summary> /// Creates a same RadFixedDocument using details text from uploaded content /// </summary> /// <param name="value">the content to use</param> /// <returns>FixedDocument that can be exported asa PDF file</returns> private static RadFixedDocument GenerateSampleDocument(MyPdfContent value) { double defaultLeftIndent = 50; double defaultLineHeight = 16; var document = new RadFixedDocument(); var page = document.Pages.AddPage(); page.Size = PageSize; var editor = new FixedContentEditor(page); editor.Position.Translate(defaultLeftIndent, 50); double currentTopOffset = 110; editor.Position.Translate(defaultLeftIndent, currentTopOffset); double maxWidth = page.Size.Width - defaultLeftIndent * 2; DocumentHelpers.DrawDescription(editor, maxWidth); currentTopOffset += defaultLineHeight * 4; editor.Position.Translate(defaultLeftIndent, currentTopOffset); using (editor.SaveProperties()) { DocumentHelpers.DrawFunnelFigure(editor); } // use the uploaded text DocumentHelpers.DrawText(editor, maxWidth, value); return(document); }
private void HighlightIncorrectUsages_CheckedChanged(object sender, EventArgs e) { ResetTheCounters(); var isFieldChecked = HighlightIncorrectUsages.Checked; if (isFieldChecked) { LogHelper.Info("Highlight incorrect usages of definition."); if (_incorrectDefinitionOccurences.Count != 0) { HighLightIncorrectUsages(); NextDefinition.Enabled = true; } else { if (HighlightAllUsages.Checked && _corectDefinitionOccurences.Count != 0) { NextDefinition.Enabled = true; } } return; } if (!HighlightAllUsages.Checked) { NextDefinition.Enabled = false; PreviousDefiniton.Enabled = false; } LogHelper.Info("Clear highlights."); DocumentHelpers.ClearHightlightOnAllInstancesOfTerm(_incorrectDefinitionOccurences); }
public static void ConvertDocumentToEditableFormat(FlowDocument document) { DocumentHelpers.ChangePropertyValue(document, TextElement.FontSizeProperty, (double)12); DocumentHelpers.ChangePropertyValue(document, TextElement.ForegroundProperty, Brushes.Black, Brushes.White); DocumentHelpers.ChangePropertyValue(document, TextElement.BackgroundProperty, Brushes.White, Brushes.Black); }
private void Document_Changed(object sender, FileSystemEventArgs e) { try { ChangeSemaphore.Wait(); var storeStream = new MemoryStream(); using (FileStream filestream = File.OpenRead(e.FullPath)) { storeStream.SetLength(filestream.Length); filestream.Read(storeStream.GetBuffer(), 0, (int)filestream.Length); storeStream.Flush(); } Application.Current.Dispatcher.Invoke((Action)(() => { DocumentHelpers.LoadDocument(storeStream, MainDocument, DataFormats.Rtf); storeStream.Dispose(); SetDocumentConfig(); })); } catch (Exception) { } finally { ChangeSemaphore.Release(); } }
public void SaveDocument(string fullFilePath) { TextRange range; FileStream fStream; try { UnWatchDocumentForChanges(fullFilePath, Document_Changed); range = new TextRange(MainDocument.ContentStart, MainDocument.ContentEnd); using (fStream = new FileStream(fullFilePath, FileMode.Create)) { DocumentHelpers.SaveDocument(fStream, MainDocument, DataFormats.Rtf); } if (fullFilePath == DocumentPath) { IsDocumentDirty = false; } string xamlPath = Path.Combine(Path.GetDirectoryName(fullFilePath), Path.GetFileNameWithoutExtension(fullFilePath) + ".xaml"); using (fStream = new FileStream(xamlPath, FileMode.Create)) { DocumentHelpers.SaveDocument(fStream, MainDocument, DataFormats.Xaml); } } finally { WatchDocumentForChanges(fullFilePath, Document_Changed); } }
private void LoadDocument(Stream documentStream, string dataFormat) { documentStream.Seek(0, SeekOrigin.Begin); DocumentHelpers.LoadDocument(documentStream, MainDocument, dataFormat); SetDocumentConfig(); SetColorScheme(); }
public void InitializeConfig() { _configInitialized = true; Speed = DefaultSpeed = Settings.Default.Speed; DocumentPath = Settings.Default.DocumentPath; if (!string.IsNullOrWhiteSpace(_documentPath) && File.Exists(DocumentPath)) { LoadDocument(DocumentPath); } else { //Load default text using (var ms = new MemoryStream(Encoding.Default.GetBytes(Resources.Proverbs_1))) { DocumentHelpers.LoadDocument(ms, MainDocument, DataFormats.Rtf); } } SetDocumentConfig(); FlipTalentWindowVert = Settings.Default.FlipTalentWindowVert; FlipTalentWindowHoriz = Settings.Default.FlipTalentWindowHoriz; FlipMainWindowVert = Settings.Default.FlipMainWindowVert; FlipMainWindowHoriz = Settings.Default.FlipMainWindowHoriz; TalentWindowLeft = Settings.Default.TalentWindowLeft; TalentWindowTop = Settings.Default.TalentWindowTop; TalentWindowWidth = Settings.Default.TalentWindowWidth; TalentWindowHeight = Settings.Default.TalentWindowHeight; FullScreenTalentWindow = Settings.Default.TalentWindowState != WindowState.Normal; SelectedTalentWindowDisplay = Settings.Default.SelectedTalentWindowDisplay; TalentWindowState = Settings.Default.TalentWindowState; EyelinePosition = Settings.Default.EyeLinePosition; if (Settings.Default.TalentWindowVisible) { ToggleTalentWindow(); } MainWindowState = Settings.Default.MainWindowState; ReceiveGlobalKeystrokes = Settings.Default.ReceiveGlobalKeystrokes; }
public void Next_Siblings_ReturnNext(string fileName, string expected) { var path = @"c:\\temp\\test\\"; string[] sibl = DocumentHelpers.Siblings(path + fileName); Assert.AreEqual(DocumentHelpers.NextSibling(sibl, fileName), expected); }
private oval_variables NewOvalVariables() { return(new oval_variables { generator = DocumentHelpers.GetDefaultGenerator(), variables = new List <OVAL.Variables.VariableType>() }); }
private async Task WriteLastEtagToDatabase(OperationState state, JsonDocument lastEtagsDocument) { lastEtagsDocument.DataAsJson = RavenJObject.FromObject(state); var stateDocument = lastEtagsDocument.ToJson(); int stateDocumentSize = (int)DocumentHelpers.GetRoughSize(stateDocument); await Operations.PutDocument(stateDocument, stateDocumentSize); }
async Task <CommandResult <SimpleDocument> > HandleAsync(GetDocument command) { var projectUri = command.ProjectId.ToKotoriProjectUri(); var documentTypeUri = command.ProjectId.ToKotoriDocumentTypeUri(command.DocumentType, command.DocumentTypeId); var project = await FindProjectAsync(command.Instance, projectUri).ConfigureAwait(false); if (project == null) { throw new KotoriProjectException(command.ProjectId, "Project does not exist.") { StatusCode = System.Net.HttpStatusCode.NotFound } } ; var d = await FindDocumentByIdAsync ( command.Instance, projectUri, command.ProjectId.ToKotoriDocumentUri(command.DocumentType, command.DocumentTypeId, command.DocumentId, command.Index), command.Version ).ConfigureAwait(false); if (d == null) { if (command.Version.HasValue) { throw new KotoriDocumentException(command.DocumentId, "Document version not found.") { StatusCode = System.Net.HttpStatusCode.NotFound } } ; throw new KotoriDocumentException(command.DocumentId, "Document not found.") { StatusCode = System.Net.HttpStatusCode.NotFound }; } return(new CommandResult <SimpleDocument> ( new SimpleDocument ( new Uri(d.Identifier).ToKotoriDocumentIdentifier().DocumentId, d.Slug, d.Meta, DocumentHelpers.PostProcessedContent(d.Content, d.Meta, command.Format), d.Date.DateTime, d.Modified.DateTime, d.Draft, d.Version ) )); } } }
public override void Undo(OutlinerDocument document, TreeListView treeListView) { OutlinerNote note = document.FindOutlinerNoteById(__NoteId); __SavedNote = note; __ColumnIndexBeforeUndo = DocumentHelpers.GetFocusedColumnIdx(treeListView, note); DocumentHelpers.DeleteRow(note, treeListView, __ColumnIndexAfterInsert); }
public void CallGetErrorMessage_WhenDocumentHasInformation_ShouldCorrectMessage(string key, string value, string exptected) { var fakeResponseDoc = new Document(); fakeResponseDoc.set(key, value); var result = DocumentHelpers.GetErrorMessage(fakeResponseDoc); Assert.Equal(exptected, result); }
public void OnlyIncludeScheduledDays() { IWorkScheduleReader reader = new HtmlWorkScheduleReader(DocumentHelpers.DocumentWithDays()); WorkSchedule workSchedule = reader.Read(); workSchedule.ShouldNotBeNull(); workSchedule.Employee.ShouldBe("John Doe"); workSchedule.WorkShifts.Count().ShouldBe(3); }
public void ReturnsAnEmptyWorkScheduleIfHtmlDocumentIsEmpty() { IWorkScheduleReader reader = new HtmlWorkScheduleReader(DocumentHelpers.EmptyDocument()); WorkSchedule workSchedule = reader.Read(); workSchedule.ShouldNotBeNull(); workSchedule.Employee.ShouldBeEmpty(); workSchedule.WorkShifts.ShouldBeEmpty(); }
public void CallIsSuccessful_WithDocumentHasStatusEqual0_ShouldReturnFalse() { var fakeResponseDoc = new Document(); fakeResponseDoc.set("Response.status", 0.ToString()); var result = DocumentHelpers.IsSuccessful(fakeResponseDoc); Assert.False(result); }
public void CallGetResponseInfo_WhenDocumentHasInformation_ShouldReturnValue(string key, string value) { var fakeResponseDoc = new Document(); fakeResponseDoc.set(key, value); var result = DocumentHelpers.GetResponseInfo(fakeResponseDoc, key); Assert.Equal(value, result); }
private async Task <int> ImportDocuments(JsonTextReader jsonReader) { var now = SystemTime.UtcNow; var count = 0; while (jsonReader.Read() && jsonReader.TokenType != JsonToken.EndArray) { Options.CancelToken.Token.ThrowIfCancellationRequested(); var document = (RavenJObject)RavenJToken.ReadFrom(jsonReader); var size = DocumentHelpers.GetRoughSize(document); if (size > 1024 * 1024) { Console.WriteLine("Large document warning: {0:#,#.##;;0} kb - {1}", (double)size / 1024, document["@metadata"].Value <string>("@id")); } if ((Options.OperateOnTypes & ItemType.Documents) != ItemType.Documents) { continue; } if (Options.MatchFilters(document) == false) { continue; } if (Options.ShouldExcludeExpired && Options.ExcludeExpired(document, now)) { continue; } if (!string.IsNullOrEmpty(Options.TransformScript)) { document = await Operations.TransformDocument(document, Options.TransformScript); } if (document == null) { continue; } await Operations.PutDocument(document, (int)size); count++; if (count % Options.BatchSize == 0) { Operations.ShowProgress("Read {0:#,#;;0} documents", count); } } await Operations.PutDocument(null, -1); // force flush return(count); }
/// <summary> /// Given position in a text buffer returns the leaf syntax node it belongs to. /// </summary> private bool TryFindLeafToken(SnapshotPoint point, out SyntaxToken token, CancellationToken cancellationToken) { var syntaxTree = DocumentHelpers.GetSyntaxTreeSynchronously(GetDocument(point, cancellationToken), cancellationToken); if (syntaxTree != null) { token = syntaxTree.GetRoot(cancellationToken).FindToken(point, true); return(true); } token = default(SyntaxToken); return(false); }