Index.razor 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. @using Microsoft.AspNetCore.Components.Rendering
  2. @using System.Web
  3. @inject NavigationManager NavigationManager
  4. <div id="test-selector">
  5. Select test:
  6. <select id="test-selector-select" @bind=SelectedComponentTypeName>
  7. <option value="none">Choose...</option>
  8. <option value="BasicTestApp.AddRemoveChildComponents">Add/remove child components</option>
  9. <option value="BasicTestApp.AfterRenderInteropComponent">After-render interop component</option>
  10. <option value="BasicTestApp.AsyncEventHandlerComponent">Async event handlers</option>
  11. <option value="BasicTestApp.AuthTest.AuthRouter">Auth cases</option>
  12. <option value="BasicTestApp.AuthTest.CascadingAuthenticationStateParent">Cascading authentication state</option>
  13. <option value="BasicTestApp.BindCasesComponent">bind cases</option>
  14. <option value="BasicTestApp.CascadingValueTest.CascadingValueSupplier">Cascading values</option>
  15. <option value="@GetTestServerProjectComponent("Components.TestServer.CircuitContextComponent")">Circuit context</option>
  16. <option value="BasicTestApp.ComponentRefComponent">Component ref component</option>
  17. <option value="BasicTestApp.ConcurrentRenderParent">Concurrent rendering</option>
  18. <option value="BasicTestApp.ConfigurationComponent">Configuration</option>
  19. <option value="BasicTestApp.ConfigureRuntime">Configure runtime</option>
  20. <option value="BasicTestApp.ContentEditable">Content-editable</option>
  21. <option value="BasicTestApp.CounterComponent">Counter</option>
  22. <option value="BasicTestApp.CounterComponentUsingChild">Counter using child component</option>
  23. <option value="BasicTestApp.CounterComponentWrapper">Counter wrapped in parent</option>
  24. <option value="BasicTestApp.CulturePicker">Culture Picker</option>
  25. <option value="BasicTestApp.CustomElementsComponent">Custom elements</option>
  26. <option value="BasicTestApp.DataDashComponent">data-* attribute rendering</option>
  27. <option value="BasicTestApp.DispatchingComponent">Dispatching to sync context</option>
  28. <option value="BasicTestApp.DuplicateAttributesComponent">Duplicate attributes</option>
  29. <option value="BasicTestApp.DynamicComponentRendering">DynamicComponent rendering</option>
  30. <option value="BasicTestApp.ElementFocusComponent">Element focus component</option>
  31. <option value="BasicTestApp.ElementRefComponent">Element ref component</option>
  32. <option value="BasicTestApp.ErrorComponent">Error throwing</option>
  33. <option value="BasicTestApp.ErrorBoundaryTest.ErrorBoundaryContainer">Error boundary cases</option>
  34. <option value="BasicTestApp.EventBubblingComponent">Event bubbling</option>
  35. <option value="BasicTestApp.EventCallbackTest.EventCallbackCases">EventCallback</option>
  36. <option value="BasicTestApp.EventCustomArgsComponent">Event custom arguments</option>
  37. <option value="BasicTestApp.EventDisablingComponent">Event disabling</option>
  38. <option value="BasicTestApp.EventDuringBatchRendering">Event during batch rendering</option>
  39. <option value="BasicTestApp.EventPreventDefaultComponent">Event preventDefault</option>
  40. <option value="BasicTestApp.ExternalContentPackage">External content package</option>
  41. <option value="BasicTestApp.FocusEventComponent">Focus events</option>
  42. <option value="BasicTestApp.FormsTest.InputFocusComponent">Input Focus</option>
  43. <option value="BasicTestApp.FormsTest.NotifyPropertyChangedValidationComponent">INotifyPropertyChanged validation</option>
  44. <option value="BasicTestApp.FormsTest.SimpleValidationComponent">Simple validation</option>
  45. <option value="BasicTestApp.FormsTest.SimpleValidationComponentUsingExperimentalValidator">Simple validation using experimental validator</option>
  46. <option value="BasicTestApp.FormsTest.ModelLevelValidationComponent">Model-level validation</option>
  47. <option value="BasicTestApp.FormsTest.TypicalValidationComponent">Typical validation</option>
  48. <option value="BasicTestApp.FormsTest.TypicalValidationComponentUsingExperimentalValidator">Typical validation using experimental validator</option>
  49. <option value="BasicTestApp.FormsTest.ValidationComponentDI">Validation with Dependency Injection</option>
  50. <option value="BasicTestApp.FormsTest.InputFileComponent">Input file</option>
  51. <option value="BasicTestApp.FormsTest.InputRangeComponent">Input range</option>
  52. <option value="BasicTestApp.FormsTest.InputsWithoutEditForm">Inputs without EditForm</option>
  53. <option value="BasicTestApp.FormsTest.InputsWithMutatingSetters">Inputs with mutating setters</option>
  54. <option value="BasicTestApp.FormsTest.InputRadioParentImplementsIHandleEvent">Input Radio Parent Implements IHandleEvent</option>
  55. <option value="BasicTestApp.NavigateOnSubmit">Navigate to submit</option>
  56. <option value="BasicTestApp.GlobalizationBindCases">Globalization Bind Cases</option>
  57. <option value="BasicTestApp.GracefulTermination">Graceful Termination</option>
  58. <option value="BasicTestApp.HeadModification">Head Modification</option>
  59. <option value="BasicTestApp.HierarchicalImportsTest.Subdir.ComponentUsingImports">Imports statement</option>
  60. <option value="BasicTestApp.HostRenderMode">Host render mode</option>
  61. <option value="BasicTestApp.HtmlBlockChildContent">ChildContent HTML Block</option>
  62. <option value="BasicTestApp.HtmlEncodedChildContent">ChildContent HTML Encoded Block</option>
  63. <option value="BasicTestApp.HtmlMixedChildContent">ChildContent Mixed Block</option>
  64. <option value="BasicTestApp.HttpClientTest.BinaryHttpRequestsComponent">Binary HttpClient tester</option>
  65. <option value="BasicTestApp.HttpClientTest.CookieCounterComponent">HttpClient cookies</option>
  66. <option value="BasicTestApp.HttpClientTest.HttpRequestsComponent">HttpClient tester</option>
  67. <option value="BasicTestApp.InputEventComponent">Input events</option>
  68. <option value="BasicTestApp.InteropComponent">Interop component</option>
  69. <option value="BasicTestApp.InteropOnInitializationComponent">Interop on initialization</option>
  70. <option value="BasicTestApp.JavaScriptRootComponents">JavaScript root components</option>
  71. <option value="BasicTestApp.JsonSerializationCases">JSON serialization</option>
  72. <option value="BasicTestApp.KeyCasesComponent">Key cases</option>
  73. <option value="BasicTestApp.KeyPressEventComponent">Key press event</option>
  74. <option value="BasicTestApp.LaggyTypingComponent">Laggy typing</option>
  75. <option value="BasicTestApp.LimitCounterComponent">Limit counter component</option>
  76. <option value="BasicTestApp.LocalizedText">Localized Text</option>
  77. <option value="BasicTestApp.LogicalElementInsertionCases">Logical element insertion cases</option>
  78. <option value="BasicTestApp.LoggingComponent">Logging</option>
  79. <option value="BasicTestApp.LongRunningInterop">Long running interop</option>
  80. <option value="BasicTestApp.MarkupBlockComponent">Markup blocks</option>
  81. <option value="BasicTestApp.MouseEventComponent">Mouse events</option>
  82. <option value="BasicTestApp.MovingCheckboxesComponent">Moving checkboxes diff case</option>
  83. <option value="BasicTestApp.MultipleChildContent">Multiple child content</option>
  84. <option value="BasicTestApp.NavigationFailureComponent">Navigation failure</option>
  85. <option value="BasicTestApp.ParentChildComponent">Parent component with child</option>
  86. <option value="BasicTestApp.PropertiesChangedHandlerParent">Parent component that changes parameters on child</option>
  87. <option value="BasicTestApp.PropertyInjection.PropertyInjectionComponent">Property injection</option>
  88. <option value="@GetTestServerProjectComponent("Components.TestServer.ProtectedBrowserStorageUsageComponent")">Protected browser storage usage</option>
  89. <option value="@GetTestServerProjectComponent("Components.TestServer.ProtectedBrowserStorageInjectionComponent")">Protected browser storage injection</option>
  90. <option value="BasicTestApp.QuickGridTest.SampleQuickGridComponent">QuickGrid Example</option>
  91. <option value="BasicTestApp.RazorTemplates">Razor Templates</option>
  92. <option value="BasicTestApp.Reconnection.ReconnectionComponent">Reconnection server-side blazor</option>
  93. <option value="BasicTestApp.RedTextComponent">Red text</option>
  94. <option value="BasicTestApp.ReliabilityComponent">Server reliability component</option>
  95. <option value="BasicTestApp.RenderFragmentToggler">Render fragment renderer</option>
  96. <option value="BasicTestApp.RenderAttributesBeforeConnectedCallback">Render attributes before ConnectedCallback</option>
  97. <option value="BasicTestApp.ReorderingFocusComponent">Reordering focus retention</option>
  98. <option value="BasicTestApp.RouterTest.NavigationManagerComponent">NavigationManager Test</option>
  99. <option value="BasicTestApp.RouterTest.TestRouter">Router</option>
  100. <option value="BasicTestApp.RouterTest.TestRouterWithOnNavigate">Router with OnNavigate</option>
  101. <option value="BasicTestApp.RouterTest.TestRouterWithLazyAssembly">Router with dynamic assembly</option>
  102. <option value="BasicTestApp.RouterTest.TestRouterWithAdditionalAssembly">Router with additional assembly</option>
  103. <option value="BasicTestApp.SelectVariantsComponent">Select with component options</option>
  104. <option value="BasicTestApp.SignalRClientComponent">SignalR client</option>
  105. <option value="BasicTestApp.StringComparisonComponent">StringComparison</option>
  106. <option value="BasicTestApp.SvgComponent">SVG</option>
  107. <option value="BasicTestApp.SvgFocusComponent">SVG Focus component</option>
  108. <option value="BasicTestApp.TextOnlyComponent">Plain text</option>
  109. <option value="BasicTestApp.ToggleEventComponent">Toggle Event</option>
  110. <option value="BasicTestApp.DialogEventsComponent">Dialog Events</option>
  111. <option value="BasicTestApp.TouchEventComponent">Touch events</option>
  112. <option value="BasicTestApp.VirtualizationComponent">Virtualization</option>
  113. <option value="BasicTestApp.VirtualizationDataChanges">Virtualization data changes</option>
  114. <option value="BasicTestApp.VirtualizationMaxItemCount">Virtualization MaxItemCount</option>
  115. <option value="BasicTestApp.VirtualizationMaxItemCount_AppContext">Virtualization MaxItemCount (via AppContext)</option>
  116. <option value="BasicTestApp.VirtualizationTable">Virtualization HTML table</option>
  117. <option value="BasicTestApp.HotReload.RenderOnHotReload">Render on hot reload</option>
  118. <option value="BasicTestApp.SectionsTest.ParentComponentWithTwoChildren">Sections test</option>
  119. <option value="BasicTestApp.SectionsTest.SectionsWithCascadingParameters">Sections with Cascading parameters test</option>
  120. <option value="BasicTestApp.SectionsTest.SectionsWithErrorBoundary">Sections with Error Boundary test</option>
  121. </select>
  122. <span id="runtime-info"><code><tt>@System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription</tt></code></span>
  123. @if (SelectedComponentType != null)
  124. {
  125. <span id="source-info"><code><tt>@(SelectedComponentType.Name.Replace(".", "/")).razor</tt></code></span>
  126. }
  127. <hr />
  128. </div>
  129. <app>
  130. @((RenderFragment)RenderSelectedComponent)
  131. </app>
  132. @code {
  133. string SelectedComponentTypeName { get; set; } = "none";
  134. Type SelectedComponentType
  135. => SelectedComponentTypeName == "none" ? null : Type.GetType(SelectedComponentTypeName, throwOnError: true);
  136. protected override void OnInitialized()
  137. {
  138. var uri = new Uri(NavigationManager.Uri);
  139. if (HttpUtility.ParseQueryString(uri.Query)["initial-component-type"] is { Length: > 0 } initialComponentTypeName)
  140. {
  141. SelectedComponentTypeName = initialComponentTypeName;
  142. }
  143. }
  144. void RenderSelectedComponent(RenderTreeBuilder builder)
  145. {
  146. if (SelectedComponentType != null)
  147. {
  148. builder.OpenComponent(0, SelectedComponentType);
  149. builder.CloseComponent();
  150. }
  151. }
  152. static string GetTestServerProjectComponent(string componentName)
  153. {
  154. var serverAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(f => f.GetName().Name == "Components.TestServer");
  155. // If the server project isn't loaded return the component name as-is. Calculating the SelectedComponentType property will result in an error.
  156. return serverAssembly is null ?
  157. componentName :
  158. serverAssembly.GetType(componentName, throwOnError: true).AssemblyQualifiedName;
  159. }
  160. }