Skip to content

Commit

Permalink
smaller diff
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalmers committed Mar 25, 2024
1 parent 2cadc9a commit 4531c2f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 47 deletions.
1 change: 0 additions & 1 deletion src/Try.Core/CompilationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
Expand Down
82 changes: 41 additions & 41 deletions src/TryMudBlazor.Client/Pages/UserPage.razor
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>


5 changes: 3 additions & 2 deletions src/TryMudBlazor.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ namespace TryMudBlazor.Client
using Services.UserPreferences;
using Try.UserComponents;
using Microsoft.AspNetCore.Components.WebAssembly.Services;
using Microsoft.AspNetCore.Components.Web;

public static class Program
public class Program
{
public static async Task Main(string[] args)
{
Expand All @@ -29,7 +30,7 @@ public static async Task Main(string[] args)
builder.Services.AddSingleton(serviceProvider => (IJSUnmarshalledRuntime)serviceProvider.GetRequiredService<IJSRuntime>());
builder.Services.AddScoped(_ => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<SnippetsService>();
builder.Services.AddSingleton<CompilationService>();
builder.Services.AddSingleton(new CompilationService());

builder.Services
.AddOptions<SnippetsOptions>()
Expand Down
4 changes: 2 additions & 2 deletions src/TryMudBlazor.Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand All @@ -21,7 +21,7 @@
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "",
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
1 change: 0 additions & 1 deletion src/UserComponents/__Main.razor
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*@

0 comments on commit 4531c2f

Please sign in to comment.