├── .gitignore ├── .vs ├── Packt │ ├── config │ │ └── applicationhost.config │ └── v16 │ │ └── .suo ├── VSWorkspaceState.json └── slnx.sqlite ├── Chapter02 ├── Demo │ ├── Demo.sln │ └── Demo │ │ ├── App.razor │ │ ├── Demo.csproj │ │ ├── Pages │ │ ├── Counter.razor │ │ ├── Counter.razor.cs │ │ ├── FetchData.razor │ │ └── Index.razor │ │ ├── Program.cs │ │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ ├── NavMenu.razor.css │ │ └── SurveyPrompt.razor │ │ ├── _Imports.razor │ │ ├── obj │ │ └── HPD │ │ │ ├── Debug │ │ │ └── net5.0 │ │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ │ ├── Demo.AssemblyInfo.cs │ │ │ │ ├── Demo.AssemblyInfoInputs.cache │ │ │ │ ├── Demo.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ ├── Demo.RazorComponent.input.cache │ │ │ │ ├── Demo.RazorComponent.output.cache │ │ │ │ ├── Demo.csprojAssemblyReference.cache │ │ │ │ └── RazorDeclaration │ │ │ │ ├── App.razor.g.cs │ │ │ │ ├── Pages │ │ │ │ ├── Counter.razor.g.cs │ │ │ │ ├── FetchData.razor.g.cs │ │ │ │ └── Index.razor.g.cs │ │ │ │ ├── Shared │ │ │ │ ├── MainLayout.razor.g.cs │ │ │ │ ├── NavMenu.razor.g.cs │ │ │ │ └── SurveyPrompt.razor.g.cs │ │ │ │ └── _Imports.razor.g.cs │ │ │ └── Release │ │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── Demo.AssemblyInfo.cs │ │ │ ├── Demo.AssemblyInfoInputs.cache │ │ │ ├── Demo.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── Demo.RazorComponent.input.cache │ │ │ ├── Demo.RazorComponent.output.cache │ │ │ └── RazorDeclaration │ │ │ ├── App.razor.g.cs │ │ │ ├── Pages │ │ │ ├── Counter.razor.g.cs │ │ │ ├── FetchData.razor.g.cs │ │ │ └── Index.razor.g.cs │ │ │ ├── Shared │ │ │ ├── MainLayout.razor.g.cs │ │ │ ├── NavMenu.razor.g.cs │ │ │ └── SurveyPrompt.razor.g.cs │ │ │ └── _Imports.razor.g.cs │ │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ ├── index.html │ │ └── sample-data │ │ └── weather.json ├── Demo_02 │ ├── CatchAll.razor │ ├── HelloWorld.razor │ └── RoutingExample.razor ├── EmptyBlazorProject.zip ├── EmptyProject │ ├── EmptyProject.sln │ └── EmptyProject │ │ ├── App.razor │ │ ├── EmptyProject.csproj │ │ ├── Pages │ │ └── Index.razor │ │ ├── Program.cs │ │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ │ ├── _Imports.razor │ │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html └── Sample │ ├── Sample.sln │ └── Sample │ ├── App.razor │ ├── Pages │ └── Index.razor │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── Sample.csproj │ ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css │ ├── _Imports.razor │ └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ ├── favicon.ico │ └── index.html ├── Chapter03 ├── Demo_03 │ ├── Alert.razor │ ├── Alert.razor.css │ └── Index.razor └── ModalDialog │ ├── ModalDialog.sln │ ├── ModalDialog │ ├── App.razor │ ├── ModalDialog.csproj │ ├── Pages │ │ └── Index.razor │ ├── Program.cs │ ├── Shared │ │ ├── Dialog.razor │ │ ├── Dialog.razor.css │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html │ └── MyComponents │ ├── BweDialog.razor │ ├── BweDialog.razor.css │ ├── Component1.razor │ ├── Component1.razor.css │ ├── ExampleJsInterop.cs │ ├── MyComponents.csproj │ ├── _Imports.razor │ └── wwwroot │ ├── background.png │ └── exampleJsInterop.js ├── Chapter04 ├── Demo_04 │ ├── App.razor │ ├── Demo_04.csproj │ ├── Pages │ │ ├── Index.razor │ │ ├── Resize.razor │ │ └── Window.razor │ ├── Program.cs │ ├── Shared │ │ ├── Document.razor │ │ ├── DocumentSync.razor │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── _Imports.razor │ ├── obj │ │ └── HPD │ │ │ ├── Debug │ │ │ └── net5.0 │ │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ │ ├── Demo_04.AssemblyInfo.cs │ │ │ │ ├── Demo_04.AssemblyInfoInputs.cache │ │ │ │ ├── Demo_04.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ ├── Demo_04.RazorComponent.input.cache │ │ │ │ ├── Demo_04.RazorComponent.output.cache │ │ │ │ ├── Demo_04.csprojAssemblyReference.cache │ │ │ │ └── RazorDeclaration │ │ │ │ ├── App.razor.g.cs │ │ │ │ ├── Pages │ │ │ │ ├── Index.razor.g.cs │ │ │ │ ├── Resize.razor.g.cs │ │ │ │ └── Window.razor.g.cs │ │ │ │ ├── Shared │ │ │ │ ├── Document.razor.g.cs │ │ │ │ ├── DocumentSync.razor.g.cs │ │ │ │ ├── MainLayout.razor.g.cs │ │ │ │ └── NavMenu.razor.g.cs │ │ │ │ └── _Imports.razor.g.cs │ │ │ └── Release │ │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── Demo_04.AssemblyInfo.cs │ │ │ ├── Demo_04.AssemblyInfoInputs.cache │ │ │ ├── Demo_04.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── Demo_04.RazorComponent.input.cache │ │ │ ├── Demo_04.RazorComponent.output.cache │ │ │ └── RazorDeclaration │ │ │ ├── App.razor.g.cs │ │ │ ├── Pages │ │ │ ├── Index.razor.g.cs │ │ │ ├── Resize.razor.g.cs │ │ │ └── Window.razor.g.cs │ │ │ ├── Shared │ │ │ ├── Document.razor.g.cs │ │ │ ├── DocumentSync.razor.g.cs │ │ │ ├── MainLayout.razor.g.cs │ │ │ └── NavMenu.razor.g.cs │ │ │ └── _Imports.razor.g.cs │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ ├── index.html │ │ └── scripts │ │ └── bweInterop.js └── LocalStorage │ ├── App.razor │ ├── LocalStorage.csproj │ ├── Pages │ └── Index.razor │ ├── Program.cs │ ├── Services │ ├── ILocalStorageService.cs │ └── LocalStorageService.cs │ ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ └── NavMenu.razor.css │ ├── _Imports.razor │ ├── obj │ └── HPD │ │ ├── Debug │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── LocalStorage.AssemblyInfo.cs │ │ │ ├── LocalStorage.AssemblyInfoInputs.cache │ │ │ ├── LocalStorage.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── LocalStorage.RazorComponent.input.cache │ │ │ ├── LocalStorage.RazorComponent.output.cache │ │ │ └── RazorDeclaration │ │ │ ├── App.razor.g.cs │ │ │ ├── Pages │ │ │ └── Index.razor.g.cs │ │ │ ├── Shared │ │ │ ├── MainLayout.razor.g.cs │ │ │ └── NavMenu.razor.g.cs │ │ │ └── _Imports.razor.g.cs │ │ └── Release │ │ └── net5.0 │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ ├── LocalStorage.AssemblyInfo.cs │ │ ├── LocalStorage.AssemblyInfoInputs.cache │ │ ├── LocalStorage.GeneratedMSBuildEditorConfig.editorconfig │ │ ├── LocalStorage.RazorComponent.input.cache │ │ ├── LocalStorage.RazorComponent.output.cache │ │ └── RazorDeclaration │ │ ├── App.razor.g.cs │ │ ├── Pages │ │ └── Index.razor.g.cs │ │ ├── Shared │ │ ├── MainLayout.razor.g.cs │ │ └── NavMenu.razor.g.cs │ │ └── _Imports.razor.g.cs │ └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ ├── favicon.ico │ ├── index.html │ └── scripts │ └── bweInterop.js ├── Chapter05 ├── .vs │ ├── VSWorkspaceState.json │ ├── ch05 │ │ └── v16 │ │ │ └── .suo │ └── slnx.sqlite ├── Sun-512.png ├── WeatherForecast │ ├── App.razor │ ├── Models │ │ ├── OpenWeather.cs │ │ └── Position.cs │ ├── Pages │ │ └── Index.razor │ ├── Program.cs │ ├── Shared │ │ ├── DailyForecast.razor │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── WeatherForecast.csproj │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ ├── images │ │ └── Sun-512.png │ │ ├── index.html │ │ ├── manifest.json │ │ ├── offline.html │ │ ├── scripts │ │ └── bweInterop.js │ │ └── service-worker.js └── weather.json ├── Chapter06 ├── ShoppingCart │ ├── App.razor │ ├── Models │ │ └── Product.cs │ ├── Pages │ │ ├── Index.razor │ │ └── Store.razor │ ├── Program.cs │ ├── Services │ │ ├── CartService.cs │ │ └── ICartService.cs │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── ShoppingCart.csproj │ ├── _Imports.razor │ ├── obj │ │ └── HPD │ │ │ ├── Debug │ │ │ └── net5.0 │ │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ │ ├── RazorDeclaration │ │ │ │ ├── App.razor.g.cs │ │ │ │ ├── Pages │ │ │ │ │ ├── Index.razor.g.cs │ │ │ │ │ └── Store.razor.g.cs │ │ │ │ ├── Shared │ │ │ │ │ ├── MainLayout.razor.g.cs │ │ │ │ │ └── NavMenu.razor.g.cs │ │ │ │ └── _Imports.razor.g.cs │ │ │ │ ├── ShoppingCart.AssemblyInfo.cs │ │ │ │ ├── ShoppingCart.AssemblyInfoInputs.cache │ │ │ │ ├── ShoppingCart.GeneratedMSBuildEditorConfig.editorconfig │ │ │ │ ├── ShoppingCart.RazorComponent.input.cache │ │ │ │ └── ShoppingCart.RazorComponent.output.cache │ │ │ └── Release │ │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── RazorDeclaration │ │ │ ├── App.razor.g.cs │ │ │ ├── Pages │ │ │ │ ├── Index.razor.g.cs │ │ │ │ └── Store.razor.g.cs │ │ │ ├── Shared │ │ │ │ ├── MainLayout.razor.g.cs │ │ │ │ └── NavMenu.razor.g.cs │ │ │ └── _Imports.razor.g.cs │ │ │ ├── ShoppingCart.AssemblyInfo.cs │ │ │ ├── ShoppingCart.AssemblyInfoInputs.cache │ │ │ ├── ShoppingCart.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── ShoppingCart.RazorComponent.input.cache │ │ │ └── ShoppingCart.RazorComponent.output.cache │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ ├── images │ │ ├── Charger.jpg │ │ ├── Earbuds.jpg │ │ ├── KeyChain.jpg │ │ ├── TShirt.jpg │ │ └── TravelMug.jpg │ │ ├── index.html │ │ └── sample-data │ │ └── products.json ├── images │ ├── Charger.jpg │ ├── Earbuds.jpg │ ├── KeyChain.jpg │ ├── TShirt.jpg │ └── TravelMug.jpg └── products.json ├── Chapter07 ├── Dropzone.razor.css └── KanbanBoard │ ├── App.razor │ ├── KanbanBoard.csproj │ ├── Models │ ├── TaskItem.cs │ └── TaskPriority.cs │ ├── Pages │ └── Index.razor │ ├── Program.cs │ ├── Shared │ ├── Dropzone.razor │ ├── Dropzone.razor.css │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ ├── NavMenu.razor.css │ └── NewTask.razor │ ├── _Imports.razor │ ├── obj │ └── HPD │ │ ├── Debug │ │ └── net5.0 │ │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ │ ├── KanbanBoard.AssemblyInfo.cs │ │ │ ├── KanbanBoard.AssemblyInfoInputs.cache │ │ │ ├── KanbanBoard.GeneratedMSBuildEditorConfig.editorconfig │ │ │ ├── KanbanBoard.RazorComponent.input.cache │ │ │ ├── KanbanBoard.RazorComponent.output.cache │ │ │ └── RazorDeclaration │ │ │ ├── App.razor.g.cs │ │ │ ├── Pages │ │ │ └── Index.razor.g.cs │ │ │ ├── Shared │ │ │ ├── Dropzone.razor.g.cs │ │ │ ├── MainLayout.razor.g.cs │ │ │ ├── NavMenu.razor.g.cs │ │ │ └── NewTask.razor.g.cs │ │ │ └── _Imports.razor.g.cs │ │ └── Release │ │ └── net5.0 │ │ ├── .NETCoreApp,Version=v5.0.AssemblyAttributes.cs │ │ ├── KanbanBoard.AssemblyInfo.cs │ │ ├── KanbanBoard.AssemblyInfoInputs.cache │ │ ├── KanbanBoard.GeneratedMSBuildEditorConfig.editorconfig │ │ ├── KanbanBoard.RazorComponent.input.cache │ │ ├── KanbanBoard.RazorComponent.output.cache │ │ └── RazorDeclaration │ │ ├── App.razor.g.cs │ │ ├── Pages │ │ └── Index.razor.g.cs │ │ ├── Shared │ │ ├── Dropzone.razor.g.cs │ │ ├── MainLayout.razor.g.cs │ │ ├── NavMenu.razor.g.cs │ │ └── NewTask.razor.g.cs │ │ └── _Imports.razor.g.cs │ └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ ├── favicon.ico │ └── index.html ├── Chapter08 ├── TaskManager.sln └── TaskManager │ ├── Client │ ├── App.razor │ ├── Pages │ │ ├── Index.razor │ │ ├── Index.razor.cs │ │ └── Index.razor.css │ ├── Program.cs │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── TaskManager.Client.csproj │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html │ ├── Server │ ├── Controllers │ │ └── TaskItemsController.cs │ ├── Data │ │ └── TaskManagerServerContext.cs │ ├── Migrations │ │ ├── 20210416185723_Init.Designer.cs │ │ ├── 20210416185723_Init.cs │ │ └── TaskManagerServerContextModelSnapshot.cs │ ├── Pages │ │ ├── Error.cshtml │ │ └── Error.cshtml.cs │ ├── Program.cs │ ├── Properties │ │ ├── launchSettings.json │ │ ├── serviceDependencies.json │ │ ├── serviceDependencies.local.json │ │ └── serviceDependencies.local.json.user │ ├── Startup.cs │ ├── TaskManager.Server.csproj │ ├── TaskManager.Server.csproj.user │ ├── appsettings.Development.json │ └── appsettings.json │ └── Shared │ ├── TaskItem.cs │ └── TaskManager.Shared.csproj ├── Chapter09 ├── ExpenseTracker.sln └── ExpenseTracker │ ├── Client │ ├── App.razor │ ├── ExpenseTracker.Client.csproj │ ├── Pages │ │ ├── ExpenseEdit.razor │ │ └── Index.razor │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── _Imports.razor │ └── wwwroot │ │ ├── css │ │ ├── app.css │ │ ├── bootstrap │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ └── open-iconic │ │ │ ├── FONT-LICENSE │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ ├── favicon.ico │ │ └── index.html │ ├── Server │ ├── Controllers │ │ ├── ExpenseTypesController.cs │ │ └── ExpensesController.cs │ ├── Data │ │ └── ExpenseTrackerServerContext.cs │ ├── ExpenseTracker.Server.csproj │ ├── ExpenseTracker.Server.csproj.user │ ├── Migrations │ │ ├── 20210422012318_Init.Designer.cs │ │ ├── 20210422012318_Init.cs │ │ └── ExpenseTrackerServerContextModelSnapshot.cs │ ├── Pages │ │ ├── Error.cshtml │ │ └── Error.cshtml.cs │ ├── Program.cs │ ├── Properties │ │ ├── launchSettings.json │ │ ├── serviceDependencies.json │ │ ├── serviceDependencies.local.json │ │ └── serviceDependencies.local.json.user │ ├── Startup.cs │ ├── appsettings.Development.json │ └── appsettings.json │ └── Shared │ ├── Expense.cs │ ├── ExpenseTracker.Shared.csproj │ └── ExpenseType.cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | /ch02/EmptyProject/EmptyProject/obj/HPD 6 | /ch02/Sample/Sample/obj/HPD 7 | /ch03/ModalDialog/ModalDialog/obj/HPD 8 | /ch03/ModalDialog/MyComponents/obj/HPD 9 | -------------------------------------------------------------------------------- /.vs/Packt/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/.vs/Packt/v16/.suo -------------------------------------------------------------------------------- /.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "" 4 | ], 5 | "SelectedNode": "\\.gitignore", 6 | "PreviewInSolutionExplorer": false 7 | } -------------------------------------------------------------------------------- /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/.vs/slnx.sqlite -------------------------------------------------------------------------------- /Chapter02/Demo/Demo.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{0D58877D-BC57-4F5F-A377-3F1D20C0BD8C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {0D58877D-BC57-4F5F-A377-3F1D20C0BD8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {0D58877D-BC57-4F5F-A377-3F1D20C0BD8C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {0D58877D-BC57-4F5F-A377-3F1D20C0BD8C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {0D58877D-BC57-4F5F-A377-3F1D20C0BD8C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3B1BCB23-B664-4D2C-BF30-AFEC0BB16EC7} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter/{increment:int}" 2 | @page "/counter" 3 | 4 |

Counter

5 | 6 |

Current count: @currentCount

7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Pages/Counter.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace Demo.Pages 8 | { 9 | public partial class Counter 10 | { 11 | [Parameter] public int? Increment { get; set; } 12 | private int increment = 1; 13 | 14 | private int currentCount = 0; 15 | 16 | private void IncrementCount() 17 | { 18 | currentCount += increment; 19 | } 20 | 21 | protected override void OnParametersSet() 22 | { 23 | if (Increment.HasValue) 24 | increment = Increment.Value; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Demo 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 |  11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using Demo 10 | @using Demo.Shared 11 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Demo")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Demo")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Demo")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 67c308b77f386c83055f63eeaffdb201ecbe925c 2 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | 94eb787e4b502a3e649ffbbc4b7b54331d6fe470 2 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/obj/HPD/Debug/net5.0/Demo.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Demo")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Demo")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Demo")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | daec21fc1f222b216b8ce9fb15619e0f7cc392a5 2 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | 94eb787e4b502a3e649ffbbc4b7b54331d6fe470 2 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/obj/HPD/Release/net5.0/Demo.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Demo/Demo/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Demo 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter02/Demo/Demo/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2018-05-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing" 6 | }, 7 | { 8 | "date": "2018-05-07", 9 | "temperatureC": 14, 10 | "summary": "Bracing" 11 | }, 12 | { 13 | "date": "2018-05-08", 14 | "temperatureC": -13, 15 | "summary": "Freezing" 16 | }, 17 | { 18 | "date": "2018-05-09", 19 | "temperatureC": -16, 20 | "summary": "Balmy" 21 | }, 22 | { 23 | "date": "2018-05-10", 24 | "temperatureC": -2, 25 | "summary": "Chilly" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /Chapter02/Demo_02/CatchAll.razor: -------------------------------------------------------------------------------- 1 | @page "/{*path}" 2 | 3 |

Catch All

4 | Route: @Path 5 | 6 | @code { 7 | [Parameter] public string Path { get; set; } 8 | } -------------------------------------------------------------------------------- /Chapter02/Demo_02/HelloWorld.razor: -------------------------------------------------------------------------------- 1 | 

Hello @Text!

2 | @code { 3 | [Parameter] public string Text { get; set; } 4 | } 5 | 6 | -------------------------------------------------------------------------------- /Chapter02/Demo_02/RoutingExample.razor: -------------------------------------------------------------------------------- 1 | @page "/routing" 2 | @page "/routing/{text}" 3 | 4 |

Blazor WebAssembly is @Text!

5 | 6 | @code { 7 | [Parameter] public string Text { get; set; } 8 | 9 | protected override void OnInitialized() 10 | { 11 | Text = Text ?? "fantastic"; 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /Chapter02/EmptyBlazorProject.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyBlazorProject.zip -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EmptyProject", "EmptyProject\EmptyProject.csproj", "{8ACABDAA-7162-4E31-8838-017CBBBBC120}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8ACABDAA-7162-4E31-8838-017CBBBBC120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {8ACABDAA-7162-4E31-8838-017CBBBBC120}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {8ACABDAA-7162-4E31-8838-017CBBBBC120}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {8ACABDAA-7162-4E31-8838-017CBBBBC120}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B8CB76B2-2E4D-4B27-B4C7-3648CBCB3484} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/EmptyProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace EmptyProject 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using EmptyProject 10 | @using EmptyProject.Shared 11 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyProject/EmptyProject/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/EmptyProject/EmptyProject/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter02/EmptyProject/EmptyProject/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | EmptyProject 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30907.101 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{21B974F6-A962-4556-BF01-DD66B0AED2B8}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {21B974F6-A962-4556-BF01-DD66B0AED2B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {21B974F6-A962-4556-BF01-DD66B0AED2B8}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {21B974F6-A962-4556-BF01-DD66B0AED2B8}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {21B974F6-A962-4556-BF01-DD66B0AED2B8}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5BE14042-491F-41F4-A576-3E1C52CC3143} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Sample 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:21839", 7 | "sslPort": 44352 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "Sample": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Sample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using Sample 10 | @using Sample.Shared 11 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Sample/Sample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter02/Sample/Sample/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter02/Sample/Sample/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Sample 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter03/Demo_03/Alert.razor: -------------------------------------------------------------------------------- 1 | @if (Show) 2 | { 3 |
4 |
5 |
6 | @ChildContent 7 |
8 |
9 | 12 |
13 |
14 |
15 | } 16 | 17 | @code { 18 | [Parameter] public bool Show { get; set; } 19 | [Parameter] public EventCallback OnOk { get; set; } 20 | [Parameter] public RenderFragment ChildContent { get; set; } 21 | } 22 | -------------------------------------------------------------------------------- /Chapter03/Demo_03/Alert.razor.css: -------------------------------------------------------------------------------- 1 | .dialog-container { 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | background-color: rgba(0,0,0,0.6); 8 | z-index: 2000; 9 | } 10 | 11 | .dialog { 12 | background-color: white; 13 | margin: auto; 14 | width: 15rem; 15 | padding: .5rem 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Chapter03/Demo_03/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | 4 |

Alert

5 |

Today is @DateTime.Now.DayOfWeek.

6 |
7 | 8 | 11 | 12 | @code { 13 | private bool showAlert = false; 14 | } -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/ModalDialog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @using MyComponents; 3 | 4 | 7 | Quick List [@(Items.Count + 1)] 8 | 9 | Enter New Item: 10 | 11 | 12 | 13 |
    14 | @foreach (var item in Items) 15 | { 16 |
  1. @item
  2. 17 | } 18 |
19 | 20 | 21 | 22 | @code { 23 | private string NewItem; 24 | private List Items = new List(); 25 | private bool showDialog = false; 26 | 27 | private void OpenDialog() 28 | { 29 | showDialog = true; 30 | } 31 | 32 | private void DialogCancelHandler(MouseEventArgs e) 33 | { 34 | NewItem = ""; 35 | showDialog = false; 36 | } 37 | 38 | private void DialogOkHandler(MouseEventArgs e) 39 | { 40 | if (!string.IsNullOrEmpty(NewItem)) 41 | { 42 | Items.Add(NewItem); 43 | NewItem = ""; 44 | }; 45 | showDialog = false; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace ModalDialog 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Shared/Dialog.razor: -------------------------------------------------------------------------------- 1 | @if (Show) 2 | { 3 |
4 |
5 |
@Title
6 |
@Body
7 |
8 | 11 | 14 |
15 |
16 |
17 | } 18 | 19 | @code { 20 | [Parameter] public bool Show { get; set; } 21 | [Parameter] 22 | public EventCallback OnOk { get; set; } 23 | [Parameter] 24 | public EventCallback OnCancel { get; set; } 25 | [Parameter] 26 | public RenderFragment Title { get; set; } 27 | [Parameter] 28 | public RenderFragment Body { get; set; } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Shared/Dialog.razor.css: -------------------------------------------------------------------------------- 1 | .dialog-container { 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | background-color: rgba(0,0,0,0.6); 8 | z-index: 2000; 9 | } 10 | 11 | .dialog { 12 | background-color: white; 13 | margin: auto; 14 | width: 25rem; 15 | } 16 | 17 | .dialog-title { 18 | background-color: #343a40; 19 | color: white; 20 | padding: .5rem; 21 | } 22 | 23 | .dialog-body { 24 | padding: 2rem; 25 | } 26 | 27 | .dialog-buttons { 28 | background-color: silver; 29 | padding: .5rem; 30 | } 31 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using ModalDialog 10 | @using ModalDialog.Shared 11 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/ModalDialog/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/ModalDialog/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter03/ModalDialog/ModalDialog/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ModalDialog 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/BweDialog.razor: -------------------------------------------------------------------------------- 1 | @if (Show) 2 | { 3 |
4 |
5 |
@Title
6 |
@Body
7 |
8 | 11 | 14 |
15 |
16 |
17 | } 18 | 19 | @code { 20 | [Parameter] public bool Show { get; set; } 21 | [Parameter] 22 | public EventCallback OnOk { get; set; } 23 | [Parameter] 24 | public EventCallback OnCancel { get; set; } 25 | [Parameter] 26 | public RenderFragment Title { get; set; } 27 | [Parameter] 28 | public RenderFragment Body { get; set; } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/BweDialog.razor.css: -------------------------------------------------------------------------------- 1 | .dialog-container { 2 | position: absolute; 3 | top: 0; 4 | bottom: 0; 5 | left: 0; 6 | right: 0; 7 | background-color: rgba(0,0,0,0.6); 8 | z-index: 2000; 9 | } 10 | 11 | .dialog { 12 | background-color: white; 13 | margin: auto; 14 | width: 25rem; 15 | } 16 | 17 | .dialog-title { 18 | background-color: #343a40; 19 | color: white; 20 | padding: .5rem; 21 | } 22 | 23 | .dialog-body { 24 | padding: 2rem; 25 | } 26 | 27 | .dialog-buttons { 28 | background-color: silver; 29 | padding: .5rem; 30 | } 31 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/Component1.razor: -------------------------------------------------------------------------------- 1 | 
2 | This Blazor component is defined in the MyComponents package. 3 |
4 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/Component1.razor.css: -------------------------------------------------------------------------------- 1 | .my-component { 2 | border: 2px dashed red; 3 | padding: 1em; 4 | margin: 1em 0; 5 | background-image: url('background.png'); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/MyComponents.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/wwwroot/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter03/ModalDialog/MyComponents/wwwroot/background.png -------------------------------------------------------------------------------- /Chapter03/ModalDialog/MyComponents/wwwroot/exampleJsInterop.js: -------------------------------------------------------------------------------- 1 | // This is a JavaScript module that is loaded on demand. It can export any number of 2 | // functions, and may import other JavaScript modules if required. 3 | 4 | export function showPrompt(message) { 5 | return prompt(message, 'Type anything here'); 6 | } 7 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Demo_04.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Pages/Resize.razor: -------------------------------------------------------------------------------- 1 | @page "/resize" 2 | 3 | @inject IJSRuntime js 4 | @implements IDisposable 5 | 6 | 7 | 8 | @if (windowSize.Width != null) 9 | { 10 |

11 | Window Size: @windowSize.Width x @windowSize.Height 12 |

13 | } 14 | 15 | @code { 16 | private DotNetObjectReference objRef; 17 | private WindowSize windowSize = new WindowSize(); 18 | 19 | protected async override Task OnAfterRenderAsync(bool firstRender) 20 | { 21 | if (firstRender) 22 | { 23 | objRef = DotNetObjectReference.Create(this); 24 | await js.InvokeVoidAsync( 25 | "bweInterop.registerResizeHandler", 26 | objRef); 27 | } 28 | } 29 | 30 | [JSInvokable] 31 | public void GetWindowSize(WindowSize newWindowSize) 32 | { 33 | windowSize = newWindowSize; 34 | StateHasChanged(); 35 | } 36 | 37 | public void Dispose() 38 | { 39 | objRef?.Dispose(); 40 | } 41 | 42 | public class WindowSize 43 | { 44 | public int? Width { get; set; } 45 | public int? Height { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Pages/Window.razor: -------------------------------------------------------------------------------- 1 | @page "/window" 2 | 3 | @inject IJSRuntime js 4 | 5 | 6 | 7 | @if (windowSize.Width != null) 8 | { 9 |

10 | Window Size: @windowSize.Width x @windowSize.Height 11 |

12 | } 13 | 14 | 15 | @code{ 16 | private WindowSize windowSize = new WindowSize(); 17 | 18 | private async Task GetWindowSize() 19 | { 20 | windowSize = await js.InvokeAsync( 21 | "bweInterop.getWindowSize"); 22 | } 23 | 24 | public class WindowSize 25 | { 26 | public int? Width { get; set; } 27 | public int? Height { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace Demo_04 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Shared/Document.razor: -------------------------------------------------------------------------------- 1 | @inject IJSRuntime js 2 | 3 | @code { 4 | [Parameter] public string Title { get; set; } 5 | 6 | protected override async Task OnAfterRenderAsync(bool firstRender) 7 | { 8 | if (firstRender) 9 | { 10 | await js.InvokeVoidAsync( 11 | "bweInterop.setDocumentTitle", 12 | Title); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Shared/DocumentSync.razor: -------------------------------------------------------------------------------- 1 | @inject IJSRuntime js 2 | 3 | @code { 4 | [Parameter] public string Title { get; set; } 5 | 6 | protected override void OnAfterRender(bool firstRender) 7 | { 8 | if (firstRender) 9 | { 10 | ((IJSInProcessRuntime)js).InvokeVoid( 11 | "bweInterop.setDocumentTitle", 12 | Title); 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using Demo_04 10 | @using Demo_04.Shared 11 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Demo_04")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Demo_04")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Demo_04")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 5c09545239ae601ea567fcda1d52559bfc9270d6 2 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | bac08ebaf0528ca5111059cf87a1fd9a67fd3c1b 2 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.csprojAssemblyReference.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/obj/HPD/Debug/net5.0/Demo_04.csprojAssemblyReference.cache -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("Demo_04")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("Demo_04")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("Demo_04")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 69cd92c512b1a9fb6275b2881dc6e31ff811e432 2 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | bac08ebaf0528ca5111059cf87a1fd9a67fd3c1b 2 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/obj/HPD/Release/net5.0/Demo_04.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/Demo_04/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | Demo_04 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Chapter04/Demo_04/wwwroot/scripts/bweInterop.js: -------------------------------------------------------------------------------- 1 | var bweInterop = {}; 2 | 3 | bweInterop.setDocumentTitle = function (title) { 4 | document.title = title; 5 | } 6 | 7 | bweInterop.getWindowSize = function () { 8 | var size = { 9 | width: window.innerWidth, 10 | height: window.innerHeight 11 | }; 12 | return size; 13 | } 14 | 15 | bweInterop.registerResizeHandler = function (dotNetObjectRef) { 16 | function resizeHandler() { 17 | dotNetObjectRef.invokeMethodAsync('GetWindowSize', 18 | { 19 | width: window.innerWidth, 20 | height: window.innerHeight 21 | }); 22 | }; 23 | 24 | resizeHandler(); 25 | 26 | window.addEventListener("resize", resizeHandler); 27 | } 28 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/LocalStorage.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @using LocalStorage.Services 4 | @inject IJSRuntime js 5 | 6 |

Local Storage Service

7 | 8 |
9 | Data: 10 | 13 |
14 |
15 | 19 | 23 |
24 | 25 | @code { 26 | private string data; 27 | private LocalStorageService localStorage; 28 | 29 | protected override void OnInitialized() 30 | { 31 | localStorage = new LocalStorageService(js); 32 | } 33 | 34 | async Task SaveToLocalStorageAsync() 35 | { 36 | await localStorage.SetItemAsync( 37 | "localStorageData", 38 | data); 39 | } 40 | 41 | async Task ReadFromLocalStorageAsync() 42 | { 43 | data = await localStorage.GetItemAsync( 44 | "localStorageData"); 45 | } 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace LocalStorage 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Services/ILocalStorageService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace LocalStorage.Services 7 | { 8 | interface ILocalStorageService 9 | { 10 | Task SetItemAsync(string key, T item); 11 | Task GetItemAsync(string key); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Services/LocalStorageService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text.Json; 6 | using System.Threading.Tasks; 7 | 8 | namespace LocalStorage.Services 9 | { 10 | public class LocalStorageService : ILocalStorageService 11 | { 12 | private IJSRuntime js; 13 | public LocalStorageService(IJSRuntime JsRuntime) 14 | { 15 | js = JsRuntime; 16 | } 17 | 18 | public async Task GetItemAsync(string key) 19 | { 20 | var json = await js.InvokeAsync("bweInterop.getLocalStorage", key); 21 | 22 | return string.IsNullOrEmpty(json) 23 | ? default 24 | : JsonSerializer.Deserialize(json); 25 | } 26 | 27 | public async Task SetItemAsync(string key, T item) 28 | { 29 | await js.InvokeVoidAsync("bweInterop.setLocalStorage", key, JsonSerializer.Serialize(item)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using LocalStorage 10 | @using LocalStorage.Shared 11 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("LocalStorage")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("LocalStorage")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("LocalStorage")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 4f2663e908bbfcaf419b6bc1179264f62a18b89e 2 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | e980b00511331af7a15b5acfb0011497a42ebfdd 2 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/obj/HPD/Debug/net5.0/LocalStorage.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("LocalStorage")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("LocalStorage")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("LocalStorage")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | d832fee983dc508ed7370c5317256602272ce98b 2 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | e980b00511331af7a15b5acfb0011497a42ebfdd 2 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/obj/HPD/Release/net5.0/LocalStorage.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter04/LocalStorage/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | LocalStorage 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Chapter04/LocalStorage/wwwroot/scripts/bweInterop.js: -------------------------------------------------------------------------------- 1 | var bweInterop = {}; 2 | 3 | bweInterop.setLocalStorage = function (key, data) { 4 | localStorage.setItem(key, data); 5 | } 6 | 7 | bweInterop.getLocalStorage = function (key) { 8 | return localStorage.getItem(key); 9 | } 10 | -------------------------------------------------------------------------------- /Chapter05/.vs/VSWorkspaceState.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExpandedNodes": [ 3 | "" 4 | ], 5 | "PreviewInSolutionExplorer": false 6 | } -------------------------------------------------------------------------------- /Chapter05/.vs/ch05/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/.vs/ch05/v16/.suo -------------------------------------------------------------------------------- /Chapter05/.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/.vs/slnx.sqlite -------------------------------------------------------------------------------- /Chapter05/Sun-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/Sun-512.png -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Models/OpenWeather.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WeatherForecast.Models 7 | { 8 | public class OpenWeather 9 | { 10 | public Daily[] Daily { get; set; } 11 | } 12 | 13 | public class Daily 14 | { 15 | public long Dt { get; set; } 16 | public Temp Temp { get; set; } 17 | public Weather[] Weather { get; set; } 18 | } 19 | 20 | public class Temp 21 | { 22 | public double Min { get; set; } 23 | public double Max { get; set; } 24 | } 25 | public class Weather 26 | { 27 | public string Description { get; set; } 28 | public string Icon { get; set; } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Models/Position.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WeatherForecast.Models 7 | { 8 | public class Position 9 | { 10 | public double Latitude { get; set; } 11 | public double Longitude { get; set; } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace WeatherForecast 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Shared/DailyForecast.razor: -------------------------------------------------------------------------------- 1 | 
2 |
3 | @Date 4 |
5 |
6 | 7 |

@Description

8 | @((int)HighTemp) F° / 9 | @((int)LowTemp) F° 10 |
11 |
12 | 13 | @code { 14 | [Parameter] public long Seconds { get; set; } 15 | [Parameter] public double HighTemp { get; set; } 16 | [Parameter] public double LowTemp { get; set; } 17 | [Parameter] public string Description { get; set; } 18 | [Parameter] public string Icon { get; set; } 19 | 20 | private string Date; 21 | private string IconUrl; 22 | 23 | protected override void OnInitialized() 24 | { 25 | Date = DateTimeOffset 26 | .FromUnixTimeSeconds(Seconds) 27 | .LocalDateTime 28 | .ToLongDateString(); 29 | IconUrl = String.Format( 30 | "https://openweathermap.org/img/wn/{0}@2x.png", 31 | Icon); 32 | } 33 | } -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/WeatherForecast.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using WeatherForecast 10 | @using WeatherForecast.Shared 11 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/images/Sun-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter05/WeatherForecast/wwwroot/images/Sun-512.png -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | WeatherForecast 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 20 |
Loading...
21 | 22 |
23 | An unhandled error has occurred. 24 | Reload 25 | 🗙 26 |
27 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "lang": "en", 3 | "name": "5-Day Weather Forecast", 4 | "short_name": "Weather", 5 | "display": "standalone", 6 | "start_url": "./", 7 | "background_color": "#ffa500", 8 | "theme_color": "transparent", 9 | "description": "This is a simple 5-day weather forecast application.", 10 | "orientation": "any", 11 | "icons": [ 12 | { 13 | "src": "images/Sun-512.png", 14 | "type": "image/png", 15 | "sizes": "512x512" 16 | } 17 | ] 18 | } 19 | 20 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/offline.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 |

You are offline.

9 | 10 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/scripts/bweInterop.js: -------------------------------------------------------------------------------- 1 | var bweInterop = {}; 2 | 3 | bweInterop.getPosition = async function () { 4 | function getPositionAsync() { 5 | return new Promise((success, error) => { 6 | navigator.geolocation.getCurrentPosition(success, error); 7 | }); 8 | } 9 | 10 | if (navigator.geolocation) { 11 | var position = await getPositionAsync(); 12 | var coords = { 13 | latitude: position.coords.latitude, 14 | longitude: position.coords.longitude 15 | }; 16 | return coords; 17 | } else { 18 | throw Error("Geolocation is not supported by this browser."); 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /Chapter05/WeatherForecast/wwwroot/service-worker.js: -------------------------------------------------------------------------------- 1 | const OFFLINE_VERSION = 1; 2 | const CACHE_PREFIX = 'offline'; 3 | const CACHE_NAME = `${CACHE_PREFIX}${OFFLINE_VERSION}`; 4 | const OFFLINE_URL = 'offline.html'; 5 | 6 | self.addEventListener('install', 7 | event => event.waitUntil(onInstall(event))); 8 | self.addEventListener('activate', 9 | event => event.waitUntil(onActivate(event))); 10 | self.addEventListener('fetch', 11 | event => event.respondWith(onFetch(event))); 12 | 13 | async function onInstall(event) { 14 | console.info('Service worker: Install'); 15 | const cache = await caches.open(CACHE_NAME); 16 | await cache.add(new Request(OFFLINE_URL)); 17 | } 18 | 19 | async function onActivate(event) { 20 | console.info('Service worker: Activate'); 21 | const cacheKeys = await caches.keys(); 22 | await Promise.all(cacheKeys 23 | .filter(key => key.startsWith(CACHE_PREFIX) 24 | && key !== CACHE_NAME) 25 | .map(key => caches.delete(key))); 26 | } 27 | 28 | async function onFetch(event) { 29 | if (event.request.method === 'GET') { 30 | try { 31 | return await fetch(event.request); 32 | } catch (error) { 33 | const cache = await caches.open(CACHE_NAME); 34 | return await cache.match(OFFLINE_URL); 35 | }; 36 | }; 37 | } 38 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace ShoppingCart.Models 7 | { 8 | public class Product 9 | { 10 | public int ProductId { get; set; } 11 | public string ProductName { get; set; } 12 | public int Price { get; set; } 13 | public string Image { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 |
4 |

Welcome to Blazing Tasks!

5 |

6 | Your one stop shop for all your tasks. 7 |

8 |
9 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using ShoppingCart.Services; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Net.Http; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace ShoppingCart 13 | { 14 | public class Program 15 | { 16 | public static async Task Main(string[] args) 17 | { 18 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 19 | builder.RootComponents.Add("#app"); 20 | 21 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 22 | builder.Services.AddScoped(); 23 | 24 | await builder.Build().RunAsync(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Services/CartService.cs: -------------------------------------------------------------------------------- 1 | using ShoppingCart.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShoppingCart.Services 8 | { 9 | public class CartService : ICartService 10 | { 11 | public IList Cart { get; private set; } 12 | public int Total { get; set; } 13 | 14 | public event Action OnChange; 15 | 16 | public CartService() { Cart = new List(); } 17 | 18 | private void NotifyStateChanged() => OnChange?.Invoke(); 19 | public void AddProduct(Product product) 20 | { 21 | Cart.Add(product); 22 | Total += product.Price; 23 | NotifyStateChanged(); 24 | } 25 | public void DeleteProduct(Product product) 26 | { 27 | Cart.Remove(product); 28 | Total -= product.Price; 29 | NotifyStateChanged(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Services/ICartService.cs: -------------------------------------------------------------------------------- 1 | using ShoppingCart.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace ShoppingCart.Services 8 | { 9 | interface ICartService 10 | { 11 | IList Cart { get; } 12 | int Total { get; set; } 13 | 14 | event Action OnChange; 15 | 16 | void AddProduct(Product product); 17 | void DeleteProduct(Product product); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 | @using ShoppingCart.Services 4 | 5 | @inject ICartService cartService 6 | 7 | @implements IDisposable 8 | 9 |
10 | 13 | 14 |
15 |
16 |

Cart Total: $@cartService.Total

17 |
18 | 19 |
20 | @Body 21 |
22 |
23 |
24 | 25 | @code{ 26 | protected override void OnInitialized() 27 | { 28 | cartService.OnChange += StateHasChanged; 29 | } 30 | 31 | public void Dispose() 32 | { 33 | cartService.OnChange -= StateHasChanged; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 23 |
24 | 25 | @code { 26 | private bool collapseNavMenu = true; 27 | 28 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 29 | 30 | private void ToggleNavMenu() 31 | { 32 | collapseNavMenu = !collapseNavMenu; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/ShoppingCart.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using ShoppingCart 10 | @using ShoppingCart.Shared 11 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("ShoppingCart")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("ShoppingCart")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("ShoppingCart")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | c15ca3383c1f57f6ee958a8b71d10c9b67a613c6 2 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | a7258e2c19e974b4205f85c70a771a4ecbe6a819 2 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/obj/HPD/Debug/net5.0/ShoppingCart.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("ShoppingCart")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("ShoppingCart")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("ShoppingCart")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | 80744c73d6d4132df85e4d0a356f6899ab8b166e 2 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | a7258e2c19e974b4205f85c70a771a4ecbe6a819 2 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/obj/HPD/Release/net5.0/ShoppingCart.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/images/Charger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/images/Charger.jpg -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/images/Earbuds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/images/Earbuds.jpg -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/images/KeyChain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/images/KeyChain.jpg -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/images/TShirt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/images/TShirt.jpg -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/images/TravelMug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/ShoppingCart/wwwroot/images/TravelMug.jpg -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ShoppingCart 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter06/ShoppingCart/wwwroot/sample-data/products.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "productId": 1, 4 | "productName": "Charger", 5 | "price": 15, 6 | "image": "charger.jpg" 7 | }, 8 | { 9 | "productId": 2, 10 | "productName": "Ear Buds", 11 | "price": 22, 12 | "image": "earbuds.jpg" 13 | }, 14 | { 15 | "productId": 3, 16 | "productName": "Key Chain", 17 | "price": 1, 18 | "image": "keychain.jpg" 19 | }, 20 | { 21 | "productId": 4, 22 | "productName": "Travel Mug", 23 | "price": 8, 24 | "image": "travelmug.jpg" 25 | }, 26 | { 27 | "productId": 5, 28 | "productName": "T-Shirt", 29 | "price": 20, 30 | "image": "tshirt.jpg" 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /Chapter06/images/Charger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/images/Charger.jpg -------------------------------------------------------------------------------- /Chapter06/images/Earbuds.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/images/Earbuds.jpg -------------------------------------------------------------------------------- /Chapter06/images/KeyChain.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/images/KeyChain.jpg -------------------------------------------------------------------------------- /Chapter06/images/TShirt.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/images/TShirt.jpg -------------------------------------------------------------------------------- /Chapter06/images/TravelMug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter06/images/TravelMug.jpg -------------------------------------------------------------------------------- /Chapter06/products.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "productId": 1, 4 | "productName": "Charger", 5 | "price": 15, 6 | "image": "charger.jpg" 7 | }, 8 | { 9 | "productId": 2, 10 | "productName": "Ear Buds", 11 | "price": 22, 12 | "image": "earbuds.jpg" 13 | }, 14 | { 15 | "productId": 3, 16 | "productName": "Key Chain", 17 | "price": 1, 18 | "image": "keychain.jpg" 19 | }, 20 | { 21 | "productId": 4, 22 | "productName": "Travel Mug", 23 | "price": 8, 24 | "image": "travelmug.jpg" 25 | }, 26 | { 27 | "productId": 5, 28 | "productName": "T-Shirt", 29 | "price": 20, 30 | "image": "tshirt.jpg" 31 | } 32 | ] 33 | -------------------------------------------------------------------------------- /Chapter07/Dropzone.razor.css: -------------------------------------------------------------------------------- 1 | .draggable { 2 | margin-bottom: 10px; 3 | padding: 10px 25px; 4 | border: 1px solid #424d5c; 5 | cursor: grab; 6 | background: #ff6a00; 7 | color: #ffffff; 8 | border-radius: 5px; 9 | width: 16rem; 10 | } 11 | 12 | .draggable:active { 13 | cursor: grabbing; 14 | } 15 | 16 | .dropzone { 17 | padding: .75rem; 18 | border: 2px solid black; 19 | min-height: 20rem; 20 | } 21 | 22 | .priority { 23 | min-width: 20rem; 24 | padding-right: 2rem; 25 | } 26 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/KanbanBoard.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Models/TaskItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace KanbanBoard.Models 7 | { 8 | public class TaskItem 9 | { 10 | public string TaskName { get; set; } 11 | public TaskPriority Priority { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Models/TaskPriority.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace KanbanBoard.Models 7 | { 8 | public enum TaskPriority 9 | { 10 | High, 11 | Medium, 12 | Low 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace KanbanBoard 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/Dropzone.razor: -------------------------------------------------------------------------------- 1 | @using KanbanBoard.Models 2 | 3 |
4 |

@Priority.ToString() Priority

5 |
8 | @foreach (var item in TaskItems 9 | .Where(q => q.Priority == Priority)) 10 | { 11 |
14 | @item.TaskName 15 | @item.Priority 16 |
17 | } 18 |
19 |
20 | 21 | @code { 22 | [Parameter] 23 | public List TaskItems { get; set; } 24 | [Parameter] 25 | public TaskPriority Priority { get; set; } 26 | [Parameter] 27 | public EventCallback OnDrop { get; set; } 28 | [Parameter] 29 | public EventCallback OnStartDrag { get; set; } 30 | 31 | private void OnDropHandler() 32 | { 33 | OnDrop.InvokeAsync(Priority); 34 | } 35 | 36 | private void OnDragStartHandler(TaskItem task) 37 | { 38 | OnStartDrag.InvokeAsync(task); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/Dropzone.razor.css: -------------------------------------------------------------------------------- 1 | .draggable { 2 | margin-bottom: 10px; 3 | padding: 10px 25px; 4 | border: 1px solid #424d5c; 5 | cursor: grab; 6 | background: #ff6a00; 7 | color: #ffffff; 8 | border-radius: 5px; 9 | width: 16rem; 10 | } 11 | 12 | .draggable:active { 13 | cursor: grabbing; 14 | } 15 | 16 | .dropzone { 17 | padding: .75rem; 18 | border: 2px solid black; 19 | min-height: 20rem; 20 | } 21 | 22 | .priority { 23 | min-width: 20rem; 24 | padding-right: 2rem; 25 | } 26 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/Shared/NewTask.razor: -------------------------------------------------------------------------------- 1 | 
2 |
3 | 6 | 11 | 16 |
17 |
18 | 19 | @code { 20 | private string taskName; 21 | 22 | [Parameter] 23 | public EventCallback OnSubmit { get; set; } 24 | [Parameter(CaptureUnmatchedValues = true)] 25 | public DictionaryInputParameters { get; set; } 26 | 27 | private async Task OnClickHandler() 28 | { 29 | if (!string.IsNullOrWhiteSpace(taskName)) 30 | { 31 | await OnSubmit.InvokeAsync(taskName); 32 | taskName = null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using KanbanBoard 10 | @using KanbanBoard.Shared 11 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("KanbanBoard")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("KanbanBoard")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("KanbanBoard")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | a0a63271305667af0bb1f96cdead281f55a66819 2 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | f317e01370346c504c3c1f77f0bbb8685673085e 2 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/obj/HPD/Debug/net5.0/KanbanBoard.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/.NETCoreApp,Version=v5.0.AssemblyAttributes.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using System.Reflection; 4 | [assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")] 5 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | using System; 12 | using System.Reflection; 13 | 14 | [assembly: System.Reflection.AssemblyCompanyAttribute("KanbanBoard")] 15 | [assembly: System.Reflection.AssemblyConfigurationAttribute("Release")] 16 | [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] 17 | [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] 18 | [assembly: System.Reflection.AssemblyProductAttribute("KanbanBoard")] 19 | [assembly: System.Reflection.AssemblyTitleAttribute("KanbanBoard")] 20 | [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] 21 | 22 | // Generated by the MSBuild WriteCodeFragment class. 23 | 24 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.AssemblyInfoInputs.cache: -------------------------------------------------------------------------------- 1 | b3f2cf2856411698e15a3d9228ecd763bad3f1f5 2 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.GeneratedMSBuildEditorConfig.editorconfig: -------------------------------------------------------------------------------- 1 | is_global = true 2 | build_property.TargetFramework = net5.0 3 | build_property.TargetPlatformMinVersion = 4 | build_property.UsingMicrosoftNETSdkWeb = 5 | build_property.ProjectTypeGuids = 6 | build_property.PublishSingleFile = 7 | build_property.IncludeAllContentForSelfExtract = 8 | build_property._SupportedPlatformList = browser 9 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.RazorComponent.input.cache: -------------------------------------------------------------------------------- 1 | f317e01370346c504c3c1f77f0bbb8685673085e 2 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.RazorComponent.output.cache: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/obj/HPD/Release/net5.0/KanbanBoard.RazorComponent.output.cache -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter07/KanbanBoard/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter07/KanbanBoard/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | KanbanBoard 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @if (tasks == null) 4 | { 5 |

Loading...

6 | } 7 | else 8 | { 9 |
10 | 11 | 15 |
16 | 17 | @foreach (var taskItem in tasks) 18 | { 19 |
21 |
22 | 23 | 24 | @taskItem.TaskName 25 | 26 |
27 |
28 | 33 | 34 |
35 |
36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Pages/Index.razor.css: -------------------------------------------------------------------------------- 1 | .completed-task { 2 | text-decoration: line-through; 3 | } 4 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace TaskManager.Client 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/TaskManager.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using TaskManager.Client 10 | @using TaskManager.Client.Shared 11 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter08/TaskManager/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter08/TaskManager/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter08/TaskManager/Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | TaskManager 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Data/TaskManagerServerContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using TaskManager.Shared; 7 | 8 | namespace TaskManager.Server.Data 9 | { 10 | public class TaskManagerServerContext : DbContext 11 | { 12 | public TaskManagerServerContext (DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet TaskItem { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Migrations/20210416185723_Init.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace TaskManager.Server.Migrations 4 | { 5 | public partial class Init : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "TaskItem", 11 | columns: table => new 12 | { 13 | TaskItemId = table.Column(type: "int", nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | TaskName = table.Column(type: "nvarchar(max)", nullable: true), 16 | IsComplete = table.Column(type: "bit", nullable: false) 17 | }, 18 | constraints: table => 19 | { 20 | table.PrimaryKey("PK_TaskItem", x => x.TaskItemId); 21 | }); 22 | } 23 | 24 | protected override void Down(MigrationBuilder migrationBuilder) 25 | { 26 | migrationBuilder.DropTable( 27 | name: "TaskItem"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace TaskManager.Server.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | [IgnoreAntiforgeryToken] 14 | public class ErrorModel : PageModel 15 | { 16 | public string RequestId { get; set; } 17 | 18 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 19 | 20 | private readonly ILogger _logger; 21 | 22 | public ErrorModel(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | public void OnGet() 28 | { 29 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace TaskManager.Server 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:10070", 7 | "sslPort": 44324 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "TaskManager.Server": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "TaskManagerServerContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "TaskManagerServerContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/Properties/serviceDependencies.local.json.user: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "restored": true, 5 | "restoreTime": "2021-04-16T18:47:49.4358469Z" 6 | } 7 | }, 8 | "parameters": {} 9 | } -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/TaskManager.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/TaskManager.Server.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ApiControllerWithContextScaffolder 5 | root/Common/Api 6 | 600 7 | 600 8 | True 9 | False 10 | True 11 | 12 | TaskManager.Server.Data.TaskManagerServerContext 13 | False 14 | 15 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ConnectionStrings": { 11 | "TaskManagerServerContext": "Server=TOI-WORK\\SQLEXPRESS2019;Database=TaskManager;Trusted_Connection=True;MultipleActiveResultSets=true" 12 | } 13 | } -------------------------------------------------------------------------------- /Chapter08/TaskManager/Shared/TaskItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace TaskManager.Shared 8 | { 9 | public class TaskItem 10 | { 11 | public int TaskItemId { get; set; } 12 | public string TaskName { get; set; } 13 | public bool IsComplete { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Chapter08/TaskManager/Shared/TaskManager.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/ExpenseTracker.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | 11 | namespace ExpenseTracker.Client 12 | { 13 | public class Program 14 | { 15 | public static async Task Main(string[] args) 16 | { 17 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 18 | builder.RootComponents.Add("#app"); 19 | 20 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 21 | 22 | await builder.Build().RunAsync(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:28411", 7 | "sslPort": 44317 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "ExpenseTracker": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 |
11 | 12 |
13 | @Body 14 |
15 |
16 |
17 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 24 |
25 | 26 | @code { 27 | private bool collapseNavMenu = true; 28 | 29 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 30 | 31 | private void ToggleNavMenu() 32 | { 33 | collapseNavMenu = !collapseNavMenu; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using ExpenseTracker.Client 10 | @using ExpenseTracker.Client.Shared 11 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter09/ExpenseTracker/Client/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Blazor-WebAssembly-by-Example/54775c0362958979805d1118621a747d8476d29b/Chapter09/ExpenseTracker/Client/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Client/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ExpenseTracker 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Loading...
16 | 17 |
18 | An unhandled error has occurred. 19 | Reload 20 | 🗙 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Data/ExpenseTrackerServerContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using ExpenseTracker.Shared; 7 | 8 | namespace ExpenseTracker.Server.Data 9 | { 10 | public class ExpenseTrackerServerContext : DbContext 11 | { 12 | public ExpenseTrackerServerContext(DbContextOptions options) 13 | : base(options) 14 | { 15 | } 16 | 17 | public DbSet ExpenseType { get; set; } 18 | 19 | public DbSet Expense { get; set; } 20 | 21 | protected override void OnModelCreating(ModelBuilder modelBuilder) 22 | { 23 | modelBuilder.Entity().HasData( 24 | new ExpenseType { Type = "Airfare", Id = 1 }, 25 | new ExpenseType { Type = "Lodging", Id = 2 }, 26 | new ExpenseType { Type = "Meal", Id = 3 }, 27 | new ExpenseType { Type = "Other", Id = 4 } 28 | ); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/ExpenseTracker.Server.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/ExpenseTracker.Server.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ApiControllerWithContextScaffolder 5 | root/Common/Api 6 | 600 7 | 600 8 | True 9 | False 10 | True 11 | 12 | ExpenseTracker.Server.Data.ExpenseTrackerServerContext 13 | False 14 | 15 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace ExpenseTracker.Server.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | [IgnoreAntiforgeryToken] 14 | public class ErrorModel : PageModel 15 | { 16 | public string RequestId { get; set; } 17 | 18 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 19 | 20 | private readonly ILogger _logger; 21 | 22 | public ErrorModel(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | public void OnGet() 28 | { 29 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace ExpenseTracker.Server 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:28411", 7 | "sslPort": 44317 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "ExpenseTracker.Server": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Properties/serviceDependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql", 5 | "connectionId": "ExpenseTrackerServerContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Properties/serviceDependencies.local.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "type": "mssql.local", 5 | "connectionId": "ExpenseTrackerServerContext" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/Properties/serviceDependencies.local.json.user: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "mssql1": { 4 | "restored": true, 5 | "restoreTime": "2021-04-22T01:17:51.7581186Z" 6 | } 7 | }, 8 | "parameters": {} 9 | } -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*", 10 | "ConnectionStrings": { 11 | "ExpenseTrackerServerContext": "Server=TOI-WORK\\SQLExpress2019;Database=ExpenseTracker;Trusted_Connection=True;MultipleActiveResultSets=true" 12 | } 13 | } -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Shared/Expense.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.ComponentModel.DataAnnotations; 7 | 8 | namespace ExpenseTracker.Shared 9 | { 10 | public class Expense 11 | { 12 | public int Id { get; set; } 13 | 14 | [Required] 15 | public DateTime? Date { get; set; } 16 | 17 | [Required] 18 | [MaxLength(100)] 19 | public string Vendor { get; set; } 20 | 21 | public string Description { get; set; } 22 | 23 | [Required] 24 | [Display(Name = "Expense Type")] 25 | public int? ExpenseTypeId { get; set; } 26 | 27 | [Required] 28 | [Range(0, 500, ErrorMessage = "The {0} field must be <= {2}.")] 29 | public decimal? Amount { get; set; } 30 | 31 | public bool Paid { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Shared/ExpenseTracker.Shared.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Chapter09/ExpenseTracker/Shared/ExpenseType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ExpenseTracker.Shared 8 | { 9 | public class ExpenseType 10 | { 11 | public int Id { get; set; } 12 | public string Type { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------