Index.cshtml 5.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. @using Microsoft.AspNetCore.Components.RenderTree
  2. <div id="test-selector">
  3. Select test:
  4. <select bind=@SelectedComponentTypeName>
  5. <option value="none">Choose...</option>
  6. <option value="BasicTestApp.InteropComponent">Interop component</option>
  7. <option value="BasicTestApp.AsyncEventHandlerComponent">Async event handlers</option>
  8. <option value="BasicTestApp.AddRemoveChildComponents">Add/remove child components</option>
  9. <option value="BasicTestApp.CounterComponent">Counter</option>
  10. <option value="BasicTestApp.CounterComponentUsingChild">Counter using child component</option>
  11. <option value="BasicTestApp.CounterComponentWrapper">Counter wrapped in parent</option>
  12. <option value="BasicTestApp.FocusEventComponent">Focus events</option>
  13. <option value="BasicTestApp.KeyPressEventComponent">Key press event</option>
  14. <option value="BasicTestApp.MouseEventComponent">Mouse events</option>
  15. <option value="BasicTestApp.TouchEventComponent">Touch events</option>
  16. <option value="BasicTestApp.InputEventComponent">Input events</option>
  17. <option value="BasicTestApp.ParentChildComponent">Parent component with child</option>
  18. <option value="BasicTestApp.PropertiesChangedHandlerParent">Parent component that changes parameters on child</option>
  19. <option value="BasicTestApp.RedTextComponent">Red text</option>
  20. <option value="BasicTestApp.RenderFragmentToggler">Render fragment renderer</option>
  21. <option value="BasicTestApp.TextOnlyComponent">Plain text</option>
  22. <option value="BasicTestApp.MarkupBlockComponent">Markup blocks</option>
  23. <option value="BasicTestApp.HierarchicalImportsTest.Subdir.ComponentUsingImports">Imports statement</option>
  24. <option value="BasicTestApp.HttpClientTest.HttpRequestsComponent">HttpClient tester</option>
  25. <option value="BasicTestApp.HttpClientTest.BinaryHttpRequestsComponent">Binary HttpClient tester</option>
  26. <option value="BasicTestApp.HttpClientTest.CookieCounterComponent">HttpClient cookies</option>
  27. <option value="BasicTestApp.BindCasesComponent">bind cases</option>
  28. <option value="BasicTestApp.DataDashComponent">data-* attribute rendering</option>
  29. <option value="BasicTestApp.ExternalContentPackage">External content package</option>
  30. <option value="BasicTestApp.SvgComponent">SVG</option>
  31. <option value="BasicTestApp.SvgWithChildComponent">SVG with child component</option>
  32. <option value="BasicTestApp.LogicalElementInsertionCases">Logical element insertion cases</option>
  33. <option value="BasicTestApp.ElementRefComponent">Element ref component</option>
  34. <option value="BasicTestApp.ComponentRefComponent">Component ref component</option>
  35. <option value="BasicTestApp.AfterRenderInteropComponent">After-render interop component</option>
  36. <option value="BasicTestApp.EventCasesComponent">Event cases</option>
  37. <option value="BasicTestApp.EventBubblingComponent">Event bubbling</option>
  38. <option value="BasicTestApp.EventPreventDefaultComponent">Event preventDefault</option>
  39. <option value="BasicTestApp.RouterTest.TestRouter">Router</option>
  40. <option value="BasicTestApp.HtmlBlockChildContent">ChildContent HTML Block</option>
  41. <option value="BasicTestApp.HtmlMixedChildContent">ChildContent Mixed Block</option>
  42. <option value="BasicTestApp.HtmlEncodedChildContent">ChildContent HTML Encoded Block</option>
  43. <option value="BasicTestApp.RazorTemplates">Razor Templates</option>
  44. <option value="BasicTestApp.MultipleChildContent">Multiple child content</option>
  45. <option value="BasicTestApp.CascadingValueTest.CascadingValueSupplier">Cascading values</option>
  46. <option value="BasicTestApp.ConcurrentRenderParent">Concurrent rendering</option>
  47. <option value="BasicTestApp.DispatchingComponent">Dispatching to sync context</option>
  48. <option value="BasicTestApp.EventCallbackTest.EventCallbackCases">EventCallback</option>
  49. <option value="BasicTestApp.FormsTest.SimpleValidationComponent">Simple validation</option>
  50. <option value="BasicTestApp.FormsTest.TypicalValidationComponent">Typical validation</option>
  51. <option value="BasicTestApp.FormsTest.NotifyPropertyChangedValidationComponent">INotifyPropertyChanged validation</option>
  52. </select>
  53. @if (SelectedComponentType != null)
  54. {
  55. <span id="source-info"><code><tt>@(SelectedComponentType.Name.Replace(".", "/")).cshtml</tt></code></span>
  56. }
  57. <hr />
  58. </div>
  59. <app>
  60. @((RenderFragment)RenderSelectedComponent)
  61. </app>
  62. @functions {
  63. string SelectedComponentTypeName { get; set; } = "none";
  64. Type SelectedComponentType
  65. => SelectedComponentTypeName == "none" ? null : Type.GetType(SelectedComponentTypeName);
  66. void RenderSelectedComponent(RenderTreeBuilder builder)
  67. {
  68. if (SelectedComponentType != null)
  69. {
  70. builder.OpenComponent(0, SelectedComponentType);
  71. builder.CloseComponent();
  72. }
  73. }
  74. }