-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
11 changed files
with
256 additions
and
221 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
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,2 +1,28 @@ | ||
# Modulight.Modules.Client.RazorComponents | ||
|
||
[![](https://buildstats.info/nuget/Modulight.Modules.Client.RazorComponents)](https://www.nuget.org/packages/Modulight.Modules.Client.RazorComponents/) | ||
|
||
Modulight provides a place to unify resources, and it can be used to make Razor component library easy to use and manage. The user needn't to take care of related services and `<script>` or `<link>` tags in `index.html`. | ||
|
||
```cs | ||
// in Startup: void ConfigureServices(ISeviceCollection services) | ||
services.AddModules(builder => { | ||
builder.UseRazorComponentClientModules().AddModule<FooModule>(); | ||
}); | ||
``` | ||
|
||
For razor components, add `ResourceDeclare` component to App.razor to load UI resources. | ||
|
||
```razor | ||
<Modulight.Modules.Client.RazorComponents.UI.ResourceDeclare /> | ||
``` | ||
|
||
This component will find all resources and global components defined in modules, and render HTML tags for them. | ||
|
||
You can also use the following codes to load resources manually (needs IJSRuntime). | ||
|
||
```cs | ||
// WebAssemblyHost host; | ||
await host.Services.GetRazorComponentClientModuleCollection().LoadResources(); | ||
``` |
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,2 +1,56 @@ | ||
# Modulight.Modules.CommandLine | ||
|
||
[![](https://buildstats.info/nuget/Modulight.Modules.CommandLine)](https://www.nuget.org/packages/Modulight.Modules.CommandLine/) | ||
|
||
```cs | ||
class Program | ||
{ | ||
public static async Task Main(string[] args) => await CreateHostBuilder(args).RunConsoleAsyncWithModules(); | ||
|
||
public static IHostBuilder CreateHostBuilder(string[] args) => | ||
Host.CreateDefaultBuilder(args) | ||
.ConfigureServices((hostContext, services) => | ||
{ | ||
services.AddModules(builder => | ||
{ | ||
builder.UseCommandLineModules().AddModule<AModule>(); | ||
}); | ||
}); | ||
} | ||
|
||
[Command] | ||
public class LogCommand : ModuleCommand<AModule> | ||
{ | ||
public LogCommand(AModule module) : base(module) | ||
{ | ||
} | ||
|
||
// Order: 0 | ||
[CommandParameter(0, Description = "Value whose logarithm is to be found.")] | ||
public double Value { get; init; } | ||
|
||
// Name: --base | ||
// Short name: -b | ||
[CommandOption("base", 'b', Description = "Logarithm base.")] | ||
public double Base { get; init; } = 10; | ||
|
||
protected override ValueTask ExecuteAsync(IConsole console, CancellationToken cancellationToken = default) | ||
{ | ||
var result = Math.Log(Value, Base); | ||
console.Output.WriteLine(result); | ||
console.Output.WriteLine($"From Module {Module.Manifest.DisplayName}."); | ||
|
||
return default; | ||
} | ||
} | ||
|
||
[CommandFrom(typeof(LogCommand))] | ||
public class AModule : CommandLineModule | ||
{ | ||
public AModule(IModuleHost host) : base(host) | ||
{ | ||
} | ||
} | ||
``` | ||
|
||
A [Sample startup](https://github.com/StardustDL/modulight/blob/master/test/Test.CommandLine/Program.cs). |
Oops, something went wrong.