Changing `@functions` block to `@code` block (#10591)

* Changing `@functions` block to `@code` block
This commit is contained in:
Artak 2019-05-29 13:36:24 -07:00 committed by GitHub
parent 443d60d8bb
commit 95d2f8ee7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
91 changed files with 133 additions and 133 deletions

View File

@ -40,7 +40,7 @@ namespace Test
var component = CompileToComponent(@"
<MyComponent bind-Value=""ParentValue"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -77,7 +77,7 @@ namespace Test
var component = CompileToComponent(@"
<MyComponent bind-Value=""ParentValue"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -114,7 +114,7 @@ namespace Test
var component = CompileToComponent(@"
<MyComponent bind-Value=""ParentValue"" bind-Value:event=""OnChanged"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -151,7 +151,7 @@ namespace Test
var component = CompileToComponent(@"
<MyComponent bind-Value=""ParentValue"" bind-Value:event=""OnChanged"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -184,7 +184,7 @@ namespace Test
var component = CompileToComponent(@"
<div bind=""@ParentValue"" />
@functions {
@code {
public string ParentValue { get; set; } = ""hi"";
}");
@ -217,7 +217,7 @@ namespace Test
var component = CompileToComponent(@"
<div bind-value=""@ParentValue"" />
@functions {
@code {
public string ParentValue { get; set; } = ""hi"";
}");
@ -252,7 +252,7 @@ namespace Test
// Act
var result = CompileToCSharp(@"
<div bind-value=""@ParentValue"" />
@functions {
@code {
public string ParentValue { get; set; } = ""hi"";
}");
@ -272,7 +272,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input bind=""@ParentValue"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -293,7 +293,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""text"" bind=""@CurrentDate"" bind:format=""MM/dd/yyyy""/>
@functions {
@code {
public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
}");
@ -315,7 +315,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""text"" bind=""@CurrentDate"" bind:format=""@Format""/>
@functions {
@code {
public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
public string Format { get; set; } = ""MM/dd/yyyy"";
@ -339,7 +339,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""text"" bind=""@ParentValue"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -361,7 +361,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""checkbox"" bind=""@Enabled"" />
@functions {
@code {
public bool Enabled { get; set; }
}");
@ -382,7 +382,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""text"" bind-value=""@ParentValue"" bind-value:event=""onchange"" />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -404,7 +404,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""text"" bind-value=""@CurrentDate"" bind-value:event=""onchange"" bind-value:format=""MM/dd"" />
@functions {
@code {
public DateTime CurrentDate { get; set; } = new DateTime(2018, 1, 1);
}");
@ -426,7 +426,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input type=""@(""text"")"" bind-value=""@ParentValue"" bind-value:event=""onchange"" visible />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -449,7 +449,7 @@ namespace Test
// Arrange
var component = CompileToComponent(@"
<input bind-value=""@ParentValue"" bind-value:event=""onchange"" type=""text"" visible />
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -477,7 +477,7 @@ namespace Test
<div bind-value=""@ParentValue"" bind-value:event=""onchange"">
<span>@(42.ToString())</span>
</div>
@functions {
@code {
public int ParentValue { get; set; } = 42;
}");
@ -502,7 +502,7 @@ namespace Test
// Arrange & Act
var generated = CompileToCSharp(@"
<input type=""text"" bind-first-second-third=""Text"" />
@functions {
@code {
public string Text { get; set; } = ""text"";
}");
@ -517,7 +517,7 @@ namespace Test
// Arrange & Act
var generated = CompileToCSharp(@"
<input type=""text"" bind-first-=""Text"" />
@functions {
@code {
public string Text { get; set; } = ""text"";
}");

View File

@ -216,7 +216,7 @@ namespace Test
var component = CompileToComponent($@"
<MyComponent OnClick=""{expression}""/>
@functions {{
@code {{
private int counter;
private void Increment(UIMouseEventArgs e) {{
counter++;
@ -261,7 +261,7 @@ namespace Test
var component = CompileToComponent(@"
<MyComponent OnClick=""@Increment""/>
@functions {
@code {
private int counter;
private void Increment(UIEventArgs e) {
counter++;
@ -446,7 +446,7 @@ namespace Test
// Act
var component = CompileToComponent(@"
<p onmouseover=""@OnComponentHover"" style=""background: @ParentBgColor;"" />
@functions {
@code {
public string ParentBgColor { get; set; } = ""#FFFFFF"";
public void OnComponentHover(UIMouseEventArgs e)

View File

@ -123,7 +123,7 @@ namespace Test
var component = CompileToComponent(@"
<GenericContext TItem=int Items=""@(new List<int>() { 1, 2, })"" ref=""_my"" />
@functions {
@code {
GenericContext<int> _my;
void Foo() { GC.KeepAlive(_my); }
}");
@ -190,7 +190,7 @@ namespace Test
var component = CompileToComponent(@"
<GenericContext Items=""@(new List<int>() { 1, 2, })"" ref=""_my"" />
@functions {
@code {
GenericContext<int> _my;
void Foo() { GC.KeepAlive(_my); }
}");
@ -223,7 +223,7 @@ namespace Test
@typeparam TItem
<GenericContext Items=""@MyItems"" ref=""_my"" />
@functions {
@code {
[Parameter] List<TItem> MyItems { get; set; }
GenericContext<TItem> _my;
void Foo() { GC.KeepAlive(_my); }

View File

@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
@foreach(var item in items) {
@item
}
@functions {
@code {
string[] items = new[] { ""First"", ""Second"", ""Third"" };
}
");
@ -296,7 +296,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange/Act
var component = CompileToComponent(
@"<elem attr=@MyHandleEvent />
@functions {
@code {
public bool HandlerWasCalled { get; set; } = false;
void MyHandleEvent(Microsoft.AspNetCore.Components.UIEventArgs eventArgs)
@ -341,7 +341,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange/Act
var component = CompileToComponent(
@"<input bind=""MyValue"" />
@functions {
@code {
public string MyValue { get; set; } = ""Initial value"";
}");
var myValueProperty = component.GetType().GetProperty("MyValue");
@ -376,7 +376,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange/Act
var component = CompileToComponent(
@"<textarea bind=""MyValue"" ></textarea>
@functions {
@code {
public string MyValue { get; set; } = ""Initial value"";
}");
var myValueProperty = component.GetType().GetProperty("MyValue");
@ -411,7 +411,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange/Act
var component = CompileToComponent(
@"<input bind=""MyDate"" />
@functions {
@code {
public DateTime MyDate { get; set; } = new DateTime(2018, 3, 4, 1, 2, 3);
}");
var myDateProperty = component.GetType().GetProperty("MyDate");
@ -449,7 +449,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
var testDateFormat = "ddd yyyy-MM-dd";
var component = CompileToComponent(
$@"<input bind=""@MyDate"" bind:format=""{testDateFormat}"" />
@functions {{
@code {{
public DateTime MyDate {{ get; set; }} = new DateTime(2018, 3, 4);
}}");
var myDateProperty = component.GetType().GetProperty("MyDate");
@ -500,7 +500,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange
var component = CompileToComponent(@"
<button onclick=""@(x => Clicked = true)"" />
@functions {
@code {
public bool Clicked { get; set; }
}");
@ -532,7 +532,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange
var component = CompileToComponent(@"
<button onclick=""@OnClick"" />
@functions {
@code {
public void OnClick(UIMouseEventArgs e) { Clicked = true; }
public bool Clicked { get; set; }
}");
@ -569,7 +569,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
// Arrange/Act
var component = CompileToComponent(
@"<input bind=""MyValue"" />
@functions {
@code {
public bool MyValue { get; set; } = true;
}");
var myValueProperty = component.GetType().GetProperty("MyValue");
@ -605,7 +605,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
var myEnumType = FullTypeName<MyEnum>();
var component = CompileToComponent(
$@"<input bind=""MyValue"" />
@functions {{
@code {{
public {myEnumType} MyValue {{ get; set; }} = {myEnumType}.{nameof(MyEnum.FirstValue)};
}}");
var myValueProperty = component.GetType().GetProperty("MyValue");
@ -695,7 +695,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
var component = CompileToComponent(@"
@(Repeat(@<div>@(""Hello, World!"".ToLower())</div>, 3))
@functions {
@code {
RenderFragment Repeat(RenderFragment template, int count)
{
return (b) =>
@ -733,7 +733,7 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
var component = CompileToComponent(@"
@(Repeat((context) => @<div>@context.ToLower()</div>, ""Hello, World!"", 3))
@functions {
@code {
RenderFragment Repeat<T>(RenderFragment<T> template, T value, int count)
{
return (b) =>

View File

@ -6,7 +6,7 @@
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -35,7 +35,7 @@ else
</table>
}
@functions {
@code {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()

View File

@ -25,7 +25,7 @@
</ul>
</div>
@functions {
@code {
bool collapseNavMenu = true;
string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

View File

@ -9,7 +9,7 @@
and tell us what you think.
</div>
@functions {
@code {
// Demonstrates how a parent component can supply parameters
[Parameter] string Title { get; set; }
}

View File

@ -6,7 +6,7 @@
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -34,7 +34,7 @@ else
</table>
}
@functions {
@code {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()

View File

@ -25,7 +25,7 @@
</ul>
</div>
@functions {
@code {
bool collapseNavMenu = true;
string NavMenuCssClass => collapseNavMenu ? "collapse" : null;

View File

@ -9,7 +9,7 @@
and tell us what you think.
</div>
@functions {
@code {
// Demonstrates how a parent component can supply parameters
[Parameter] string Title { get; set; }
}

View File

@ -3,7 +3,7 @@
Hello, world!
@functions {
@code {
protected override void OnAfterRender()
{
BenchmarkEvent.Send(JSRuntime, "Rendered index.cshtml");

View File

@ -22,7 +22,7 @@
<p>Deserialized <strong id="deserialized-count">@numPeopleDeserialized</strong> people</p>
}
@functions {
@code {
static string[] Clearances = new[] { "Alpha", "Beta", "Gamma", "Delta", "Epsilon" };
Person smallOrgChart = GenerateOrgChart(1, 4);
Person largeOrgChart = GenerateOrgChart(5, 4);

View File

@ -32,7 +32,7 @@ Number of items: <input id="num-items" type="number" bind=@numItems />
</table>
}
@functions {
@code {
int numItems = 10;
bool show = false;

View File

@ -6,7 +6,7 @@
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -43,7 +43,7 @@ else
</p>
}
@functions {
@code {
[Parameter] DateTime StartDate { get; set; }
WeatherForecast[] forecasts;

View File

@ -25,7 +25,7 @@
</ul>
</div>
@functions {
@code {
bool collapseNavMenu = true;
void ToggleNavMenu()

View File

@ -4,7 +4,7 @@
<CascadingValue T="Task<AuthenticationState>" Value="@_currentAuthenticationStateTask" ChildContent="@ChildContent" />
@functions {
@code {
private Task<AuthenticationState> _currentAuthenticationStateTask;
/// <summary>

View File

@ -8,7 +8,7 @@ Child components follow.
<p><MessageComponent Message=@message /></p>
}
@functions {
@code {
int numAdded = 0;
List<string> currentChildrenMessages = new List<string>();

View File

@ -3,7 +3,7 @@
<input ref="myInput" value="Value set during render" />
@functions {
@code {
ElementRef myInput;
protected override void OnAfterRender()

View File

@ -6,7 +6,7 @@
<button id="tock" onclick="@Tock">Tock</button>
</div>
@functions
@code
{
TaskCompletionSource<object> _tcs;
string state = "Stopped";

View File

@ -22,7 +22,7 @@
<hr />
<Links />
@functions {
@code {
protected override void OnInit()
{
// Start at AuthHome, not at any other component in the same app that happens to

View File

@ -32,7 +32,7 @@ else
</p>
}
@functions
@code
{
static Predicate<Claim> TestClaimPredicate = c => c.Type == "test-claim";

View File

@ -137,7 +137,7 @@
<button id="select-box-add-option" onclick="@AddAndSelectNewSelectOption">Add and select new item</button>
</p>
@functions {
@code {
string textboxInitiallyBlankValue = null;
string textboxInitiallyPopulatedValue = "Hello";

View File

@ -10,7 +10,7 @@
Flag 2: <strong id="flag-2">@MyFlag2</strong>
</p>
@functions {
@code {
[CascadingParameter(Name = "TestFlag1")] bool MyFlag1 { get; set; }
[CascadingParameter(Name = "TestFlag2")] bool MyFlag2 { get; set; }
}

View File

@ -3,6 +3,6 @@
<strong id="current-count">@CurrentCounter.NumClicks</strong>
</p>
@functions {
@code {
[CascadingParameter] CounterDTO CurrentCounter { get; set; }
}

View File

@ -16,7 +16,7 @@
<button id="decrement-count" onclick=@Ancestor.DecrementCount>Decrement</button>
</p>
@functions {
@code {
int numRenders = 0;
[CascadingParameter] ICanDecrement Ancestor { get; set; }

View File

@ -20,7 +20,7 @@
<p><label><input type="checkbox" id="toggle-flag-1" bind=currentFlagValue1 /> Flag 1</label></p>
<p><label><input type="checkbox" id="toggle-flag-2" bind=currentFlagValue2 /> Flag 2</label></p>
@functions {
@code {
CounterDTO counterState = new CounterDTO { NumClicks = 100 };
bool currentFlagValue1;
bool currentFlagValue2;

View File

@ -24,7 +24,7 @@
</label>
</fieldset>
@functions {
@code {
bool _toggleCapturedComponentPresence = true;
CounterComponent _myChildCounter;

View File

@ -1,5 +1,5 @@
<span>@(isAfterDelay ? "😊" :"WAITING")</span>
@functions
@code
{
protected bool isAfterDelay;

View File

@ -12,7 +12,7 @@
<p id="listening-message">Listening</p>
}
@functions {
@code {
int currentCount = 0;
bool handleClicks = true;

View File

@ -5,7 +5,7 @@
<button onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -1,5 +1,5 @@
<div id="cool_beans" data-tab="@TabId">@TabId</div>
@functions {
@code {
string TabId = "17";
}

View File

@ -15,7 +15,7 @@
<button id="run-with-double-dispatch" onclick=@RunWithDoubleDispatch>Run with double dispatch</button>
<button id="run-async-with-dispatch" onclick=@RunAsyncWorkWithDispatch>Run async work with dispatch</button>
@functions {
@code {
string result;
async Task RunWithoutDispatch()

View File

@ -25,7 +25,7 @@
Toggle input
</label>
@functions {
@code {
int _count = 0;
bool _toggleCapturedElementPresence = true;
ElementRef _myInput;

View File

@ -24,7 +24,7 @@
<textarea readonly bind="@logValue"></textarea>
@functions {
@code {
string logValue = string.Empty;
void LogEvent(string message)

View File

@ -1,7 +1,7 @@
<button onclick="@OnClick">@Text</button>
@functions {
@code {
[Parameter] int Count { get; set; }
[Parameter] EventCallback<int> CountChanged { get; set; }
[Parameter] string Text { get; set; }

View File

@ -35,7 +35,7 @@
<ButtonComponent bind-Count="buttonComponentCount" Text="Unbound Lambda Bind-To-Component" />
</div>
@functions {
@code {
int renderCount;
int buttonComponentCount = 1; // Avoid CS0649

View File

@ -1,7 +1,7 @@
<button onclick="@OnClick">@Text</button>
@functions {
@code {
[Parameter] EventCallback OnClick { get; set; }
[Parameter] string Text { get; set; }
}

View File

@ -1,7 +1,7 @@
<InnerButton OnClick="@OnClick" Text="@Text"/>
@functions {
@code {
[Parameter] EventCallback OnClick { get; set; }
[Parameter] string Text { get; set; }
}

View File

@ -1,7 +1,7 @@
<button onclick="@OnClick">@Text</button>
@functions {
@code {
[Parameter] EventCallback<UIMouseEventArgs> OnClick { get; set; }
[Parameter] string Text { get; set; }
}

View File

@ -3,6 +3,6 @@
@ChildContent
</div>
@functions {
@code {
[Parameter] RenderFragment ChildContent { get; set; }
}

View File

@ -28,7 +28,7 @@
<p id="event-handled">Event was handled</p>
}
@functions {
@code {
bool didHandleEvent;
async Task HandleClick()

View File

@ -29,7 +29,7 @@
<ComponentFromPackage />
@functions
@code
{
string result;

View File

@ -16,7 +16,7 @@
Another input (to distract you) <input id="other" />
</p>
@functions {
@code {
string message;
@ -48,4 +48,4 @@
{
message = string.Empty;
}
}
}

View File

@ -12,7 +12,7 @@
</p>
<p>
This example also shows that you don't strictly have to use EditForm. You can manually
cascade an EditContext to the components that integrate with it.
cascade an EditContext to the components that integrate with it.
</p>
<form onsubmit="@HandleSubmit">
@ -34,7 +34,7 @@
<div id="submission-status">@submissionStatus</div>
@functions {
@code {
MyModel person = new MyModel();
EditContext editContext;
string submissionStatus;

View File

@ -28,7 +28,7 @@
<span id="last-callback">@lastCallback</span>
}
@functions {
@code {
string lastCallback;
[Required(ErrorMessage = "Please choose a username")]

View File

@ -50,7 +50,7 @@
<ul>@foreach (var entry in submissionLog) { <li>@entry</li> }</ul>
@functions {
@code {
Person person = new Person();
// Usually this would be in a different file

View File

@ -20,7 +20,7 @@
<span id="test-outcome">@testOutcome</span>
@functions {
@code {
string uri = "";
HttpStatusCode? responseStatusCode;
string responseStatusText;

View File

@ -11,7 +11,7 @@
<p id="response-text">@responseText</p>
}
@functions
@code
{
bool requestInProgress = false;
string testServerBaseUrl;

View File

@ -60,7 +60,7 @@
}
</style>
@functions {
@code {
string uri = "http://api.icndb.com/jokes/random";
string method = "GET";
string requestBody = "";

View File

@ -70,7 +70,7 @@
@((RenderFragment)RenderSelectedComponent)
</app>
@functions {
@code {
string SelectedComponentTypeName { get; set; } = "none";
Type SelectedComponentType

View File

@ -4,6 +4,6 @@
<p id="test-result">@inputText</p>
@functions {
@code {
string inputText { get; set; }
}

View File

@ -51,7 +51,7 @@
<p id="done-with-interop">Done with interop.</p>
}
@functions {
@code {
public IDictionary<string, string> ReturnValues { get; set; } = new Dictionary<string, string>();
public IDictionary<string, string> Invocations { get; set; } = new Dictionary<string, string>();

View File

@ -22,7 +22,7 @@
<input id="val-set-by-interop" ref="@myElem" />
</p>
@functions {
@code {
string infoFromJs;
ElementRef myElem;

View File

@ -25,7 +25,7 @@
.key-cases .node .node .children { margin-left: 1.1rem; }
</style>
@functions {
@code {
string modelJson = @"{
""label"": ""root"",
""children"": [

View File

@ -32,7 +32,7 @@
}
</div>
@functions {
@code {
public class Node
{
public object Key { get; set; }

View File

@ -8,7 +8,7 @@ Type here: <input onkeypress=@OnKeyPressed />
}
</ul>
@functions {
@code {
List<string> keysPressed = new List<string>();
void OnKeyPressed(UIKeyboardEventArgs eventArgs)

View File

@ -24,7 +24,7 @@
@((MarkupString)myMarkup)
@functions {
@code {
bool changeOutput;
string myMarkup = "<p class='markup-string-value'>This is a <em>markup string</em>.</p>";

View File

@ -1,4 +1,4 @@
<span style="color: red" class="message">@Message</span>
@functions {
@code {
[Parameter] string Message { get; set; }
}

View File

@ -24,7 +24,7 @@
</p>
</div>
@functions {
@code {
string message;
@ -72,4 +72,4 @@
{
message = string.Empty;
}
}
}

View File

@ -13,7 +13,7 @@
Toggle: <input type="checkbox" bind="ShowFooter" id="toggle"/>
@functions {
@code {
List<Item> Items { get; } = new List<Item>()
{
new Item(){ Col1 = "a0", Col2 = "b0", Col3 = "c0", },
@ -29,4 +29,4 @@ Toggle: <input type="checkbox" bind="ShowFooter" id="toggle"/>
public string Col2 { get; set; }
public string Col3 { get; set; }
}
}
}

View File

@ -10,7 +10,7 @@
}
</ol>
@functions{
@code{
[Parameter] IEnumerable<TItem> Items { get; set; }
[Parameter] RenderFragment<Context> Template { get; set; }
@ -21,4 +21,4 @@
public TItem Item { get; set; }
}
}
}

View File

@ -1,5 +1,5 @@
@ChildContent
@functions {
@code {
// Note: The lack of any whitespace or other output besides @ChildContent is important for
// what scenarios this component is used for in E2E tests.

View File

@ -15,7 +15,7 @@
<button id="increment-count" onclick="@(() => count++)">Click me</button>
</p>
@functions {
@code {
int count;
bool firstRender = false;
protected override Task OnAfterRenderAsync()

View File

@ -1,7 +1,7 @@
<div class="supplied">You supplied: @SuppliedValue</div>
<div class="computed">I computed: @computedValue</div>
@functions {
@code {
[Parameter]
int SuppliedValue { get; set; }

View File

@ -1,6 +1,6 @@
<PropertiesChangedHandlerChild SuppliedValue=@valueToSupply />
<button onclick=@(x => valueToSupply++)>Increment</button>
@functions {
@code {
private int valueToSupply = 100;
}

View File

@ -10,7 +10,7 @@
<p>The end</p>
</div>
@functions {
@code {
bool showFragment;
static RenderFragment ExampleFragment = builder =>

View File

@ -30,7 +30,7 @@
}
</ul>
@functions {
@code {
Random rng = new Random();
TodoItem[] todoItems = new[]
{

View File

@ -5,7 +5,7 @@
<span id="test-info">@UrlLocation</span>
@functions{
@code{
string UrlLocation;
protected override void OnInit()

View File

@ -1,7 +1,7 @@
@page "/WithNumberParameters/{TestInt:int}/{TestLong:long}/{TestDouble:double}/{TestFloat:float}/{TestDec:decimal}"
<div id="test-info">Test parameters: @TestInt @TestLong @TestDouble @TestFloat @TestDec</div>
@functions
@code
{
[Parameter] int TestInt { get; set; }
[Parameter] long TestLong { get; set; }

View File

@ -3,7 +3,7 @@
<div id="test-info">Your full name is @FirstName @LastName.</div>
<Links />
@functions
@code
{
[Parameter] string FirstName { get; set; }

View File

@ -4,6 +4,6 @@
<button onclick=@(() => { radius *= 2; })>Click me</button>
@functions {
@code {
int radius = 10;
}

Before

Width:  |  Height:  |  Size: 220 B

After

Width:  |  Height:  |  Size: 215 B

View File

@ -20,7 +20,7 @@
}
</table>
@functions {
@code {
[Parameter]
RenderFragment Header { get; set; }
@ -32,4 +32,4 @@
[Parameter]
IReadOnlyList<TItem> Items { get; set; }
}
}

View File

@ -21,7 +21,7 @@
</p>
</div>
@functions {
@code {
string message;
@ -36,4 +36,4 @@
{
message = string.Empty;
}
}
}

View File

@ -7,6 +7,6 @@
<Router AppAssembly=typeof(ComponentsApp.App.App).Assembly />
</CascadingValue>
@functions{
@code{
[Parameter] public string Name { get; set; }
}

View File

@ -6,7 +6,7 @@
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -3,13 +3,13 @@
<h1>Error</h1>
@if(ShouldCauseError)
{
throw new InvalidOperationException("Exception while rendering");
throw new InvalidOperationException("Exception while rendering");
}
else
{
<button id="cause-error" onclick="@CauseError">Cause error</button>
}
@functions {
@code {
public bool ShouldCauseError { get; set; }
void CauseError()

View File

@ -43,7 +43,7 @@ else
</p>
}
@functions {
@code {
[Parameter] DateTime StartDate { get; set; }
WeatherForecast[] forecasts;

View File

@ -3,6 +3,6 @@
<h1>Greeter</h1>
<p class="greeting">Hello @Name</p>
@functions {
@code {
[CascadingParameter(Name=nameof(Name))] public string Name { get; set; }
}

View File

@ -5,7 +5,7 @@
<h1>Ticker</h1>
<p class="tick-value">@tick</p>
@functions {
@code {
int tick;
private bool _isDisposed;

View File

@ -45,7 +45,7 @@
</ul>
</div>
@functions {
@code {
bool collapseNavMenu = true;
void ToggleNavMenu()

View File

@ -4,7 +4,7 @@
<button onclick="@ChangeLabel">@buttonLabel </button>
</div>
@functions {
@code {
string buttonLabel = "Click me";
void ChangeLabel()

View File

@ -35,7 +35,7 @@ else
</table>
}
@functions {
@code {
[Parameter] DateTime StartDate { get; set; }
WeatherForecast[] forecasts;

View File

@ -1,7 +1,7 @@
@page "/components/throws"
@* This is expected to throw and result in a 500 *@
@functions {
@code {
protected override async Task OnInitAsync()
{
await base.OnInitAsync();

View File

@ -1,5 +1,5 @@
<h3>Component1</h3>
@functions {
@code {
}

View File

@ -6,7 +6,7 @@
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
@functions {
@code {
int currentCount = 0;
void IncrementCount()

View File

@ -35,7 +35,7 @@ else
</table>
}
@functions {
@code {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()

View File

@ -31,7 +31,7 @@
</NotAuthorized>
</AuthorizeView>
@functions {
@code {
bool canEditProfile;
protected override void OnInit()

View File

@ -25,7 +25,7 @@
</ul>
</div>
@functions {
@code {
bool collapseNavMenu = true;
string NavMenuCssClass => collapseNavMenu ? "collapse" : null;