forked from BlazorRepl/BlazorRepl
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cadc9a
commit 4531c2f
Showing
5 changed files
with
46 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
@page "/user-page" | ||
|
||
<MudContainer Class="mt-8"> | ||
<MudText>This snippet hasn't been compiled yet.</MudText> | ||
<MudText>Run the code on the left to see the result here.</MudText> | ||
<MudText Typo="@Typo.h6" Class="mt-12">How to load your own service</MudText> | ||
<MudText Class="mt-3"> | ||
To install a service which your snippet can use create a new *.cs file, <br/> | ||
define a <code class="mud-primary-text">class UserStartup</code> with a <code class="mud-primary-text">public static void Configure(WebAssemblyHostBuilder builder)</code>. | ||
</MudText> | ||
<br/> | ||
<MudText>Here is an example. Note the required usings!</MudText> | ||
<pre class="mt-6"> | ||
namespace Try.UserComponents | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
// required using for UserStartup: | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public class UserStartup | ||
{ | ||
public static void Configure(WebAssemblyHostBuilder builder) { | ||
builder.Services.AddSingleton(new MyService()); | ||
} | ||
} | ||
|
||
// your service | ||
public class MyService { | ||
public string Hello() => "Hello World from MyService!"; | ||
} | ||
|
||
@page "/user-page" | ||
|
||
<MudContainer Class="mt-8"> | ||
<MudText>This snippet hasn't been compiled yet.</MudText> | ||
<MudText>Run the code on the left to see the result here.</MudText> | ||
<MudText Typo="@Typo.h6" Class="mt-12">How to load your own service</MudText> | ||
<MudText Class="mt-3"> | ||
To install a service which your snippet can use create a new *.cs file, <br/> | ||
define a <code class="mud-primary-text">class UserStartup</code> with a <code class="mud-primary-text">public static void Configure(WebAssemblyHostBuilder builder)</code>. | ||
</MudText> | ||
<br/> | ||
<MudText>Here is an example. Note the required usings!</MudText> | ||
<pre class="mt-6"> | ||
namespace Try.UserComponents | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
// required using for UserStartup: | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
public class UserStartup | ||
{ | ||
public static void Configure(WebAssemblyHostBuilder builder) { | ||
builder.Services.AddSingleton(new MyService()); | ||
} | ||
} | ||
|
||
// your service | ||
public class MyService { | ||
public string Hello() => "Hello World from MyService!"; | ||
} | ||
|
||
} | ||
</pre> | ||
</MudContainer> | ||
|
||
|
||
</pre> | ||
</MudContainer> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@page "/__main" | ||
|
||
@namespace Try.UserComponents | ||
@using Microsoft.AspNetCore.Components.Web | ||
@*This serves as a stub, which is then replaced with the user's components on the fly*@ |