Linked e-resources
Details
Table of Contents
Cover
Title Page
Copyright and Credits
Contributors
Table of Contents
Preface
Chapter 1: Introducing Blazor, gRPC, and Source Generators
Technical requirements
Using the Blazor framework to create websites
Using Blazor WebAssembly for single-page applications
Harnessing advantages of progressive web applications using Blazor
Understanding how Blazor uses Razor syntax
Using JavaScript in Blazor
Understanding the REST API as the default Blazor communication interface
Understanding gRPC and how it is different from REST
How protocol buffers work
Why we still use REST
What are source generators and how do they work?
Summary
Further reading
Chapter 2: Creating a Blazor WebAssembly Application
Technical requirements
Learning how to write Razor syntax
Writing implicit Razor expressions
Writing explicit Razor expressions
Writing inline expressions
Writing code block expressions
Writing control structures
Writing top-level directives
Writing inline directives
Creating Razor components
Using components in other components
Passing parameters to components
Creating components with child content
Communicating with the parent component
Understanding the component life cycle
Structuring component code
Understanding page routing in Blazor
Navigating between pages
Page directive
Route constraints
Catch-all parameters
Project overview and preparation
Creating a demo Blazor WebAssembly project
Examining the project
Preparing the demo project
Summary
Chapter 3: Creating a Database Using Entity Framework Core
Technical requirements
Creating a data repository using EF
Installing NuGet packages
Enabling EF
Creating database representation in C#
Configuring EF Core
Migrating code to the database.
Creating entities in the database
Using generic services for data manipulation
Creating models
Mappings between models
Creating data services
Creating a new record
Reading a single record
Reading all records
Updating records
Deleting records
Registering data services
Summary
Further reading
Chapter 4: Connecting Client and Server with REST API
Technical requirements
Exposing CRUD operations in API controllers
Consuming a REST API in Blazor components
Creating and editing data
Viewing the data
Extending the demo project
Summary
Chapter 5: Building gRPC Services
Technical requirements
What are the benefits of using gRPC services?
How does communication work in gRPC?
Understanding the protocol buffer language
Creating messages
Field types
Default values
The reserved keyword
Defining methods
gRPC services in C#
Two ways of implementing
Implementing gRPC services using .proto files
Creating Blazor components
Preparation for generic components
Creating generic list components
Creating generic form components
Summary
Chapter 6: Diving Deep into Source Generators
Technical requirements
What can source generators generate?
What is a syntax tree?
What is a semantic model?
Implementing source generators
Using partial classes and methods
Partial classes
Partial methods
Creating attributes for your needs
Writing the first generator
Required packages
Limiting the generator
Generating the code
Referencing the generators
Exploring generated code
Summary
Chapter 7: Best Practices for C# and gRPC
gRPC is not the new REST
Generated code can be harder to debug
Exploring generated code
Using a debugger
Emitting generated files
Testing the generator
Type less, generate more
Summary.
Index
Other Books You May Enjoy.
Title Page
Copyright and Credits
Contributors
Table of Contents
Preface
Chapter 1: Introducing Blazor, gRPC, and Source Generators
Technical requirements
Using the Blazor framework to create websites
Using Blazor WebAssembly for single-page applications
Harnessing advantages of progressive web applications using Blazor
Understanding how Blazor uses Razor syntax
Using JavaScript in Blazor
Understanding the REST API as the default Blazor communication interface
Understanding gRPC and how it is different from REST
How protocol buffers work
Why we still use REST
What are source generators and how do they work?
Summary
Further reading
Chapter 2: Creating a Blazor WebAssembly Application
Technical requirements
Learning how to write Razor syntax
Writing implicit Razor expressions
Writing explicit Razor expressions
Writing inline expressions
Writing code block expressions
Writing control structures
Writing top-level directives
Writing inline directives
Creating Razor components
Using components in other components
Passing parameters to components
Creating components with child content
Communicating with the parent component
Understanding the component life cycle
Structuring component code
Understanding page routing in Blazor
Navigating between pages
Page directive
Route constraints
Catch-all parameters
Project overview and preparation
Creating a demo Blazor WebAssembly project
Examining the project
Preparing the demo project
Summary
Chapter 3: Creating a Database Using Entity Framework Core
Technical requirements
Creating a data repository using EF
Installing NuGet packages
Enabling EF
Creating database representation in C#
Configuring EF Core
Migrating code to the database.
Creating entities in the database
Using generic services for data manipulation
Creating models
Mappings between models
Creating data services
Creating a new record
Reading a single record
Reading all records
Updating records
Deleting records
Registering data services
Summary
Further reading
Chapter 4: Connecting Client and Server with REST API
Technical requirements
Exposing CRUD operations in API controllers
Consuming a REST API in Blazor components
Creating and editing data
Viewing the data
Extending the demo project
Summary
Chapter 5: Building gRPC Services
Technical requirements
What are the benefits of using gRPC services?
How does communication work in gRPC?
Understanding the protocol buffer language
Creating messages
Field types
Default values
The reserved keyword
Defining methods
gRPC services in C#
Two ways of implementing
Implementing gRPC services using .proto files
Creating Blazor components
Preparation for generic components
Creating generic list components
Creating generic form components
Summary
Chapter 6: Diving Deep into Source Generators
Technical requirements
What can source generators generate?
What is a syntax tree?
What is a semantic model?
Implementing source generators
Using partial classes and methods
Partial classes
Partial methods
Creating attributes for your needs
Writing the first generator
Required packages
Limiting the generator
Generating the code
Referencing the generators
Exploring generated code
Summary
Chapter 7: Best Practices for C# and gRPC
gRPC is not the new REST
Generated code can be harder to debug
Exploring generated code
Using a debugger
Emitting generated files
Testing the generator
Type less, generate more
Summary.
Index
Other Books You May Enjoy.