public void should_pull_code_example_from_folder() { var path = Path.GetTempPath() + Guid.NewGuid().ToString(); Directory.CreateDirectory(path); try { File.WriteAllText(Path.Combine(path, "CodeExampleWithCommentsAndTemplate.md"), "*comments*"); File.WriteAllText(Path.Combine(path, "CodeExampleWithCommentsAndTemplate.mustache"), "some<br/>template \r\nyo"); File.WriteAllText(Path.Combine(path, "CodeExampleWithNoTemplate.md"), "*comments*"); File.WriteAllText(Path.Combine(path, "CodeExampleWithNoComments.mustache"), "some<br/>template \r\nyo"); var examples = CodeExample.FromDirectory(path).ToList(); examples[0].Name.ShouldEqual("CodeExampleWithCommentsAndTemplate"); examples[0].Comments.ShouldEqual(CompiledComments); examples[0].Template.ShouldEqual(PreProcessedTemplate); examples[1].Name.ShouldEqual("CodeExampleWithNoComments"); examples[1].Comments.ShouldEqual(null); examples[1].Template.ShouldEqual(PreProcessedTemplate); examples[2].Name.ShouldEqual("CodeExampleWithNoTemplate"); examples[2].Comments.ShouldEqual(CompiledComments); examples[2].Template.ShouldEqual(null); } finally { Directory.Delete(path, true); } }
public void should_pull_code_example_from_embedded_resource(string filename, string name, string comments, string template) { var examples = CodeExample.FromEmbeddedResource(ThisAssembly, filename, name); examples.Name.ShouldEqual(name ?? filename); examples.Comments.ShouldEqual(comments); examples.Template.ShouldEqual(template); }
public IActionResult Create([FromBody] CodeExample item) { if (item == null) { return(BadRequest()); } item.Id = 0; _context.CodeExamples.Add(item); _context.SaveChanges(); return(CreatedAtRoute("GetExample", new { id = item.Id }, item)); }
void OnNewExampleSelected(object sender, FocusedNodeChangedEventArgs e) { CodeExample newExample = (sender as TreeList).GetDataRecordByNode(e.Node) as CodeExample; CodeExample oldExample = (sender as TreeList).GetDataRecordByNode(e.OldNode) as CodeExample; if (newExample == null) { return; } string exampleCode = codeEditor.ShowExample(oldExample, newExample); CodeEvaluationEventArgs args = new CodeEvaluationEventArgs(); InitializeCodeEvaluationEventArgs(args); //evaluator.ForceCompile(args); }
void treeList_VirtualTreeGetCellValue(object sender, VirtualTreeGetCellValueInfo args) { CodeExampleGroup group = args.Node as CodeExampleGroup; if (group != null) { args.CellData = group.Name; } CodeExample example = args.Node as CodeExample; if (example != null) { args.CellData = example.RegionName; } }
void OnNewExampleSelected(object sender, FocusedNodeChangedEventArgs e) { CodeExample newExample = (sender as TreeList).GetDataRecordByNode(e.Node) as CodeExample; CodeExample oldExample = (sender as TreeList).GetDataRecordByNode(e.OldNode) as CodeExample; if (newExample == null) { return; } string exampleCode = codeEditor.ShowExample(oldExample, newExample); codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example"; CodeEvaluationEventArgs args = new CodeEvaluationEventArgs(); InitializeCodeEvaluationEventArgs(args); //evaluator.ForceCompile(args); }
void SuppressExamples(List <CodeExampleGroup> examples) { for (int i = 0; i < examples.Count; i++) { CodeExampleGroup group = examples[i]; if (group.Name == "View Options Actions") { for (int j = 0; j < group.Examples.Count; j++) { CodeExample example = group.Examples[j]; if (example.RegionName == "Smooth Lines") { group.Examples.RemoveAt(j); break; } } break; } } }
public bool CreateExample(ExampleCreate model) { using (var context = new ApplicationDbContext()) { var entity = new CodeExample { CodeExampleId = model.CodeExampleId, CategoryId = model.CategoryId, ProfileId = _userId, Title = model.Title, ExampleCode = model.ExampleCode, ExampleDescription = model.ExampleDescription, InitialPost = DateTimeOffset.Now, EditedPost = null }; context.CodeExamples.Add(entity); return(context.SaveChanges() == 1); } }
public IActionResult Update(long id, [FromBody] CodeExample item) { if (item == null || item.Id != id) { return(BadRequest()); } var codeExample = _context.CodeExamples.FirstOrDefault(t => t.Id == id); if (codeExample == null) { return(NotFound()); } codeExample.Title = item.Title; codeExample.Description = item.Description; codeExample.Url = item.Url; codeExample.ImageUrl = item.ImageUrl; _context.CodeExamples.Update(codeExample); _context.SaveChanges(); return(new NoContentResult()); }
private void OnNewExampleSelected(object sender, CurrentItemChangedEventArgs e) { CodeExample newExample = e.NewItem as CodeExample; CodeExample oldExample = e.OldItem as CodeExample; if (newExample == null) { return; } if (codeEditor == null) { return; } string exampleCode = codeEditor.ShowExample(oldExample, newExample); codeExampleNameLbl.Content = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example"; CodeEvaluationEventArgs args = new CodeEvaluationEventArgs(); InitializeCodeEvaluationEventArgs(args); evaluator.ForceCompile(args); }
public App() { MainPage = new CodeExample(); // MainPage = new XamlExample(); }
/// <summary> /// Adds a code examples to the documentation from a folder. /// These are named as [filename].[md] for comments and [filename].[mustache] /// for templates. The name defaults to the filename if not specified. /// </summary> public Swank WithCodeExampleFolder(string path) { _configuration.CodeExamples.AddRange(CodeExample.FromDirectory(HostingEnvironment.MapPath( (!path.StartsWith("\\") && !path.StartsWith("\\") ? "~\\" : "") + path))); return(this); }
/// <summary> /// Adds a code example to the documentation from an embedded resource. /// These are named as [filename].[md] for comments and [filename].[mustache] /// for templates. The name defaults to the filename if not specified. /// </summary> public Swank WithCodeExampleResource(string filename, string name = null) { _configuration.CodeExamples.Add(CodeExample.FromEmbeddedResource( _configuration.AppliesToAssemblies, filename, name)); return(this); }