You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
3.4 KiB
Plaintext
173 lines
3.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# 使用 Razor 进行交互式展示"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 添加 Nuget 包"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"dotnet_interactive": {
|
|
"language": "csharp"
|
|
},
|
|
"polyglot_notebook": {
|
|
"kernelName": "csharp"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>RazorInteractive, 1.2.0</span></li></ul></div></div>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"Loading extensions from `C:\\Users\\ruyu\\.nuget\\packages\\razorinteractive\\1.2.0\\lib\\net8.0\\RazorInteractive.dll`"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
},
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<details>\n",
|
|
" <summary>Renders the code block as Razor markup in dotnet-interactive notebooks.</summary>\n",
|
|
" <p>This extension adds a new kernel that can render Razor markdown.</p>\n",
|
|
" <p>All C# and F# variables are available in the <code>@Model</code> property.</p>\n",
|
|
"</details>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"// 可以先添加包源\n",
|
|
"\n",
|
|
"#r \"nuget: RazorInteractive\""
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 添加引用"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"dotnet_interactive": {
|
|
"language": "csharp"
|
|
},
|
|
"polyglot_notebook": {
|
|
"kernelName": "csharp"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"#!razor"
|
|
]
|
|
},
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## 示例"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"dotnet_interactive": {
|
|
"language": "razor"
|
|
},
|
|
"polyglot_notebook": {
|
|
"kernelName": "razor"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div id=\"razorExtensionb930c7bdda2b4b3f97f814d8c76d64e8\"> \n",
|
|
"<ol>\n",
|
|
" <li style=\"color: red;\">red</li>\n",
|
|
" <li style=\"color: green;\">green</li>\n",
|
|
" <li style=\"color: blue;\">blue</li>\n",
|
|
"</ol></div>"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"#!razor\n",
|
|
"\n",
|
|
"@{\n",
|
|
" var colors = new [] { \"red\", \"green\", \"blue\" };\n",
|
|
"}\n",
|
|
" \n",
|
|
"<ol>\n",
|
|
" @foreach(var color in colors)\n",
|
|
" {\n",
|
|
" <li style=\"color: @color;\">@color</li>\n",
|
|
" }\n",
|
|
"</ol>"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".NET (C#)",
|
|
"language": "C#",
|
|
"name": ".net-csharp"
|
|
},
|
|
"language_info": {
|
|
"name": "polyglot-notebook"
|
|
},
|
|
"orig_nbformat": 4,
|
|
"polyglot_notebook": {
|
|
"kernelInfo": {
|
|
"defaultKernelName": "csharp",
|
|
"items": [
|
|
{
|
|
"aliases": [],
|
|
"name": "csharp"
|
|
},
|
|
{
|
|
"aliases": [],
|
|
"name": "razor"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|