-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
4dae5f1
commit f6165ff
Showing
87 changed files
with
61,027 additions
and
228 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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
<h1>RSCG nr 172 : GoLive.Generator.BlazorInterop</h1> | ||
|
||
<h2>Info</h2> | ||
Nuget : <a href="https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/" target="_blank">https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/</a> | ||
|
||
<p>You can find more details at : <a href="https://github.com/surgicalcoder/BlazorInteropGenerator" target="_blank"> https://github.com/surgicalcoder/BlazorInteropGenerator</a></p> | ||
|
||
<p>Author :surgicalcoder</p> | ||
|
||
<p>Source : <a href="https://github.com/surgicalcoder/BlazorInteropGenerator" target="_blank">https://github.com/surgicalcoder/BlazorInteropGenerator</a> </p> | ||
|
||
<h2>About</h2> | ||
|
||
Generating interop from C# to javascript for Blazor | ||
|
||
<h2> | ||
How to use | ||
</h2> | ||
<h3> | ||
Add reference to the <a href="https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/" target="_blank">GoLive.Generator.BlazorInterop</a> in the csproj | ||
</h3> | ||
<img src="images/GoLive.Generator.BlazorInterop/MyTestBlazoe.csproj.png" width="580" height="580" /> | ||
|
||
<h3>This was for me the <b>starting</b> code</h3> | ||
|
||
<br /> | ||
I have <b>coded</b> the file BlazorInterop.json | ||
<br /> | ||
<img src="images/GoLive.Generator.BlazorInterop/csFiles/BlazorInterop.json.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file blazorinterop.js | ||
<br /> | ||
<img src="images/GoLive.Generator.BlazorInterop/csFiles/blazorinterop.js.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file Home.razor | ||
<br /> | ||
<img src="images/GoLive.Generator.BlazorInterop/csFiles/Home.razor.png" width="580" height="580" /> | ||
<hr /> | ||
|
||
<br /> | ||
I have <b>coded</b> the file index.html | ||
<br /> | ||
<img src="images/GoLive.Generator.BlazorInterop/csFiles/index.html.png" width="580" height="580" /> | ||
<hr /> | ||
<h3>And here are the <i>generated</i> files</h3> | ||
|
||
<br /> | ||
The file <i>generated</i> is Generated.JSInterop.cs | ||
<br /> | ||
<img src="images/GoLive.Generator.BlazorInterop/generated/Generated.JSInterop.cs.png" width="580" height="580" /> | ||
|
||
<p> | ||
You can download the code and this page as pdf from | ||
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/GoLive.Generator.BlazorInterop'> | ||
https://ignatandrei.github.io/RSCG_Examples/v2/docs/GoLive.Generator.BlazorInterop | ||
</a> | ||
</p> | ||
|
||
|
||
<p> | ||
You can see the whole list at | ||
<a target="_blank" href='https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG'> | ||
https://ignatandrei.github.io/RSCG_Examples/v2/docs/List-of-RSCG | ||
</a> | ||
</p> | ||
|
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
22 changes: 22 additions & 0 deletions
22
v2/rscg_examples/GoLive.Generator.BlazorInterop/description.json
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"generator":{ | ||
"name":"GoLive.Generator.BlazorInterop", | ||
"nuget":[ | ||
"https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/" | ||
], | ||
"link":"https://github.com/surgicalcoder/BlazorInteropGenerator", | ||
"author":"surgicalcoder", | ||
"source":"https://github.com/surgicalcoder/BlazorInteropGenerator" | ||
}, | ||
"data":{ | ||
"goodFor":["Generating interop from C# to javascript for Blazor"], | ||
"csprojDemo":"MyTestBlazoe.csproj", | ||
"csFiles":["BlazorInterop.json","blazorinterop.js","Home.razor","index.html"], | ||
"excludeDirectoryGenerated":["Microsoft.CodeAnalysis.Razor.Compiler"], | ||
"includeAdditionalFiles":[""] | ||
}, | ||
"links":{ | ||
"blog":"", | ||
"video":"" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Generates strongly typed methods that interop into Javascript. |
42 changes: 42 additions & 0 deletions
42
v2/rscg_examples/GoLive.Generator.BlazorInterop/readme.txt
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# BlazorInteropGenerator | ||
Generates Blazor -> Javascript strongly typed interop methods, by parsing the Javascript it self and generating extension methods for IJSRuntime. | ||
|
||
## Usage | ||
|
||
Firstly, add the project from Nuget - [GoLive.Generator.BlazorInterop](https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/), then add an AdditionalFile in your .csproj named "BlazorInterop.json", like so: | ||
|
||
``` | ||
<ItemGroup> | ||
<AdditionalFiles Include="BlazorInterop.json" /> | ||
</ItemGroup> | ||
``` | ||
|
||
Once that's done, add the settings file and change as required: | ||
|
||
|
||
``` | ||
{ | ||
"Files": [ | ||
{ | ||
"Output": "JSInterop.cs", | ||
"Source": "wwwroot\\blazorinterop.js", | ||
"Namespace": "GoLive.Generator.BlazorInterop.Playground.Client", | ||
"ObjectToInterop": "window.blazorInterop", | ||
"Init": ["window={}"] | ||
} | ||
], | ||
"InvokeVoidString": "await JSRuntime.InvokeVoidAsync(\"{0}\", {1});", | ||
"InvokeString": "return await JSRuntime.InvokeAsync of T (\"{0}\",{1});" | ||
} | ||
|
||
``` | ||
|
||
### Description of Each Option | ||
- Files: An array of file objects specifying details of the files involved in the interop process. | ||
- Output: The name of the output C# file to be generated. | ||
- Source: The path to the source JavaScript file used for the interop. | ||
- Namespace: The namespace used in the generated C# file. | ||
- ObjectToInterop: The JavaScript object used for the interop. | ||
- Init: An array of initialization scripts executed before the interop. In this example above, we are interop'ing to window.blazorInterop, and window doesn't exist, so we have to create it. | ||
- InvokeVoidString: A template string for invoking a JavaScript function that does not return a value using JSRuntime.InvokeVoidAsync. Placeholders {0} and {1} are replaced with the function name and arguments, respectively. | ||
- InvokeString: A template string for invoking a JavaScript function that returns a value using JSRuntime.InvokeAsync of T . Placeholders {0} and {1} are replaced with the function name and arguments, respectively. |
48 changes: 48 additions & 0 deletions
48
...cg_examples/GoLive.Generator.BlazorInterop/src/.tours/GoLive.Generator.BlazorInterop.tour
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
{ | ||
"$schema": "https://aka.ms/codetour-schema", | ||
"title": "GoLive.Generator.BlazorInterop", | ||
"steps": | ||
[ | ||
{ | ||
"file": "MyTestBlazoe/MyTestBlazoe.csproj", | ||
"description": "First, we add Nuget [GoLive.Generator.BlazorInterop](https://www.nuget.org/packages/GoLive.Generator.BlazorInterop/) in csproj ", | ||
"pattern": "GoLive.Generator.BlazorInterop" | ||
} | ||
|
||
,{ | ||
"file": "MyTestBlazoe/wwwroot/index.html", | ||
"description": "File index.html ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "MyTestBlazoe/Pages/Home.razor", | ||
"description": "File Home.razor ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "MyTestBlazoe/wwwroot/blazorinterop.js", | ||
"description": "File blazorinterop.js ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
,{ | ||
"file": "MyTestBlazoe/BlazorInterop.json", | ||
"description": "File BlazorInterop.json ", | ||
"pattern": "this is the code" | ||
} | ||
|
||
|
||
,{ | ||
"file": "MyTestBlazoe/obj/GX/GoLive.Generator.BlazorInterop/GoLive.Generator.BlazorInterop.JSInteropGenerator/Generated.JSInterop.cs", | ||
"description": "Generated File 1 from 1 : Generated.JSInterop.cs ", | ||
"line": 1 | ||
} | ||
|
||
], | ||
|
||
"ref": "main" | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
v2/rscg_examples/GoLive.Generator.BlazorInterop/src/MyTestBlazoe.sln
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.13.35507.96 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyTestBlazoe", "MyTestBlazoe\MyTestBlazoe.csproj", "{CB1E78AD-C395-48A8-9E8B-8AEB48CB8198}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CB1E78AD-C395-48A8-9E8B-8AEB48CB8198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CB1E78AD-C395-48A8-9E8B-8AEB48CB8198}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CB1E78AD-C395-48A8-9E8B-8AEB48CB8198}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CB1E78AD-C395-48A8-9E8B-8AEB48CB8198}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
12 changes: 12 additions & 0 deletions
12
v2/rscg_examples/GoLive.Generator.BlazorInterop/src/MyTestBlazoe/App.razor
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
14 changes: 14 additions & 0 deletions
14
v2/rscg_examples/GoLive.Generator.BlazorInterop/src/MyTestBlazoe/BlazorInterop.json
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Files": [ | ||
{ | ||
"Output_DeleteThis_ToHave_InYourProject": "JSInterop.cs", | ||
"ClassName": "JSInterop", | ||
"Source": "wwwroot\\blazorinterop.js", | ||
"Namespace": "GoLive.Generator.BlazorInterop.Playground.Client", | ||
"ObjectToInterop": "window.blazorInterop", | ||
"Init": ["window={}"] | ||
} | ||
], | ||
"InvokeVoidString": "await JSRuntime.InvokeVoidAsync(\"{0}\", {1});", | ||
"InvokeString": "return await JSRuntime.InvokeAsync<T>(\"{0}\",{1});" | ||
} |
16 changes: 16 additions & 0 deletions
16
v2/rscg_examples/GoLive.Generator.BlazorInterop/src/MyTestBlazoe/Layout/MainLayout.razor
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@inherits LayoutComponentBase | ||
<div class="page"> | ||
<div class="sidebar"> | ||
<NavMenu /> | ||
</div> | ||
|
||
<main> | ||
<div class="top-row px-4"> | ||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a> | ||
</div> | ||
|
||
<article class="content px-4"> | ||
@Body | ||
</article> | ||
</main> | ||
</div> |
77 changes: 77 additions & 0 deletions
77
v2/rscg_examples/GoLive.Generator.BlazorInterop/src/MyTestBlazoe/Layout/MainLayout.razor.css
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
.page { | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
main { | ||
flex: 1; | ||
} | ||
|
||
.sidebar { | ||
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); | ||
} | ||
|
||
.top-row { | ||
background-color: #f7f7f7; | ||
border-bottom: 1px solid #d6d5d5; | ||
justify-content: flex-end; | ||
height: 3.5rem; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.top-row ::deep a, .top-row ::deep .btn-link { | ||
white-space: nowrap; | ||
margin-left: 1.5rem; | ||
text-decoration: none; | ||
} | ||
|
||
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
.top-row ::deep a:first-child { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
@media (max-width: 640.98px) { | ||
.top-row { | ||
justify-content: space-between; | ||
} | ||
|
||
.top-row ::deep a, .top-row ::deep .btn-link { | ||
margin-left: 0; | ||
} | ||
} | ||
|
||
@media (min-width: 641px) { | ||
.page { | ||
flex-direction: row; | ||
} | ||
|
||
.sidebar { | ||
width: 250px; | ||
height: 100vh; | ||
position: sticky; | ||
top: 0; | ||
} | ||
|
||
.top-row { | ||
position: sticky; | ||
top: 0; | ||
z-index: 1; | ||
} | ||
|
||
.top-row.auth ::deep a:first-child { | ||
flex: 1; | ||
text-align: right; | ||
width: 0; | ||
} | ||
|
||
.top-row, article { | ||
padding-left: 2rem !important; | ||
padding-right: 1.5rem !important; | ||
} | ||
} |
Oops, something went wrong.