1. Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.com
Blazor in Action 1st Edition Chris Sainty
https://ebookmeta.com/product/blazor-in-action-1st-edition-
chris-sainty/
OR CLICK HERE
DOWLOAD EBOOK
Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com
2. Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.
Blazor Succinctly 1st Edition Michael Washington
https://ebookmeta.com/product/blazor-succinctly-1st-edition-michael-
washington/
ebookmeta.com
Blazor WebAssembly Succinctly 1st Edition Michael
Washington
https://ebookmeta.com/product/blazor-webassembly-succinctly-1st-
edition-michael-washington/
ebookmeta.com
Microsoft Blazor, 2nd Edition Peter Himschoot
https://ebookmeta.com/product/microsoft-blazor-2nd-edition-peter-
himschoot/
ebookmeta.com
Vander's Human Physiology: The Mechanisms of Body Function
16th Edition Eric Widmaier
https://ebookmeta.com/product/vanders-human-physiology-the-mechanisms-
of-body-function-16th-edition-eric-widmaier/
ebookmeta.com
3. Azure Security For Critical Workloads: Implementing Modern
Security Controls for Authentication, Authorization and
Auditing 1st Edition Sagar Lad
https://ebookmeta.com/product/azure-security-for-critical-workloads-
implementing-modern-security-controls-for-authentication-
authorization-and-auditing-1st-edition-sagar-lad/
ebookmeta.com
Machine Learning Methods 1st Edition Hang Li
https://ebookmeta.com/product/machine-learning-methods-1st-edition-
hang-li/
ebookmeta.com
Logging Frameworks in Java 1st Edition Neha Kaul
https://ebookmeta.com/product/logging-frameworks-in-java-1st-edition-
neha-kaul/
ebookmeta.com
Peterson s Principles of Oral and Maxillofacial Surgery
4th Edition Michael Miloro
https://ebookmeta.com/product/peterson-s-principles-of-oral-and-
maxillofacial-surgery-4th-edition-michael-miloro/
ebookmeta.com
SafeHaven 1st Edition Xander Jade
https://ebookmeta.com/product/safehaven-1st-edition-xander-jade/
ebookmeta.com
4. Global health Ethical challenges 2nd Edition Solomon
Benatar
https://ebookmeta.com/product/global-health-ethical-challenges-2nd-
edition-solomon-benatar/
ebookmeta.com
10. Blazor in Action
CHRIS SAINTY
To comment go to liveBook
Manning
Shelter Island
For more information on this and other Manning titles go to
www.manning.com
13. that end. Recognizing also our responsibility to conserve the
resources of our planet, Manning books are printed on
paper that is at least 15 percent recycled and processed
without the use of elemental chlorine.
Manning Publications Co.
20 Baldwin Road Technical
PO Box 761
Shelter Island, NY 11964
Development editors: Toni Arritola and Kristen Watterson
Technical development editor: Andrew West
14. Review editor: Aleksandar Dragosavljević
Production editor: Andy Marinkovich
Copyeditor: Carrie Andrews
Proofreader: Keri Hales
Technical proofreader: Karthikeyarajan Rajendran
Typesetter and cover designer: Marija Tudor
17. contents
front matter
preface
acknowledgments
about this book
about the author
about the cover illustration
1 Starting your Blazor journey
1.1 Why choose Blazor for new applications?
1.2 Components, a better way to build UI
What is a component?
The benefits of a component-based UI
Anatomy of a Blazor component
1.3 Blazor, a platform for building modern UIs with C#
Understanding hosting models
Blazor WebAssembly
Blazor Server
Other hosting models 16
2 Your first Blazor app
18. 2.1 Setting up the application
Blazor WebAssembly template configurations
Creating the application
2.2 Building and running the application
2.3 Key components of a Blazor application
Index.html
Program.cs
App.razor
wwwroot folder and _Imports.razor 30
2.4 Writing your first components
Organizing files using feature folders
Setting up styling
Defining the layout
The Blazing Trails home page
3 Working with Blazor’s component model
19. 3.1 Structuring components
Single file
Partial class
3.2 Component life cycle methods
The first render
The life cycle with async
Dispose: The extra life cycle method 60
3.3 Working with parent and child components
Passing values from a parent to a child
Passing data from a child to a parent
3.4 Styling components
Global styling
Scoped styling
Using CSS preprocessors
4 Routing
4.1 Introducing client-side routing
Blazor’s router
Defining page components
4.2 Navigating between pages programmatically
4.3 Passing data between pages using route parameters
4.4 Handling multiple routes with a single component
4.5 Working with query strings
Setting query-string values
Retrieving query-string values using
SupplyParameterFromQuery
5 Forms and validation—Part 1: Fundamentals
20. 5.1 Super-charging forms with components
Creating the model
Basic EditForm configuration
Collecting data with input components
Creating inputs on demand 120
5.2 Validating the model
Configuring validation rules with Fluent Validation
Configuring Blazor to use Fluent Validation 125
5.3 Submitting data to the server
Adding MediatR to the Blazor project
Creating a request and handler to post the form data to the API
Setting up the endpoint 136
6 Forms and validation—Part 2: Beyond the basics
21. 6.1 Customizing validation CSS classes
Creating a FieldCssClassProvider
Using custom FieldCssClassProviders with EditForm
6.2 Building custom input components with InputBase
Inheriting from InputBase<T>
Styling the custom component
Using the custom input component
6.3 Working with files
Configuring the InputFile component
Uploading files when the form is submitted
6.4 Updating the form to allow editing
Separating the trail form into a standalone component
Refactoring AddTrailPage.razor
Adding the edit trail feature
Testing the edit functionality 177
7 Creating more reusable components
7.1 Defining templates
7.2 Enhancing templates with generics
7.3 Sharing components with Razor class libraries
8 Integrating with JavaScript libraries
22. 8.1 Creating a JavaScript module and accessing it via a
component
Testing out the RouteMap component
Calling JavaScript functions from C# and returning a response
8.2 Calling C# methods from JavaScript
8.3 Integrating the RouteMap component with the
TrailForm
8.4 Displaying the RouteMap on the TrailDetails drawer
9 Securing Blazor applications
9.1 Integrating with an identity provider: Auth
Registering applications with Auth
Customizing tokens from Auth
Configuring Blazor WebAssembly to use Auth
Configuring ASP.NET Core WebAPI to use Auth
9.2 Displaying different UI fragments based on
authentication status
Updating the Home feature
9.3 Prevent unauthorized users accessing a page
Securing API endpoints
Calling secure API endpoints from Blazor
9.4 Authorizing users by role
Adding roles in Auth
Consuming Auth0 roles in Blazor WebAssembly
Implementing role-based logic
10 Managing state
23. 10.1 Simple state management using an in-memory store
Creating and registering a state store
Saving data entered on the form to AppState
10.2 Improving the AppState design to handle more state
10.3 Creating persistent state with browser local storage
Defining an additional state store
Adding and removing trails from the favorites list
Displaying the current number of favorite trails
Reorganizing and refactoring
Showing favorited trails on the favorite trails page
Initializing AppState
11 Testing your Blazor application
11.1 Introducing bUnit
11.2 Adding a bUnit test project
11.3 Testing components with bUnit
Testing rendered markup
Triggering event handlers
Faking authentication and authorization
Emulating JavaScript interactions
Testing multiple components 287
appendix A Adding an ASP.NET Core backend to a
Blazor WebAssembly app
appendix B Updating existing areas to use the API
index
24. front matter
preface
I’ve been an ASP.NET developer for over 17 years now. I
love working with ASP.NET Core and the C# language. But
there was always an element missing for me. . . .
Since I was young, I’ve enjoyed building web UIs. When I
was 15, my best friend and I decided to build a website
about the Quake games we enjoyed playing. He built the
backend while I built the UI. I remember spending hours
and days creating nested tables and inline styles to create
the look we wanted for the site. This seems torturous now,
but I really loved it at the time. Throughout my resulting
career, I’ve really enjoyed building the client-side
experience, but this has always taken me away from C#
and ASP.NET Core. Instead, I’ve learned JavaScript and
various frameworks and tooling that are popular in that
ecosystem. While I enjoyed JavaScript, I really wanted to
be using my favorite language, C#, when building client-
side web applications.
Then one day in February 2018, I stumbled across a video
of Steve Sanderson at NDC Oslo 2017
(https://youtu.be/MiLAE6HMr10). In this talk, he presented an
experiment he had built that took a portable .NET run time
called Dot Net Anywhere and compiled it to a format called
25. WebAssembly. He used this as a base to create a framework
that allowed client-side web applications to be built using
Razor (a mix of C#, HTML, and CSS) that ran entirely in the
browser. He called it Blazor.
The first experimental preview of Blazor was released by
Microsoft on March 22, 2018, with new previews almost
every month. I followed along with each preview, trying out
the new features and writing blog posts about my
experiences. On April 18, 2019, Daniel Roth published a
blog post announcing that it was moving out of the
experimental phase and Microsoft had committed to ship it
as a supported web UI framework. Finally, the missing
element!
Since that blog post, Blazor has gone from strength to
strength. Additional hosting models have been added,
allowing Blazor to run in more places. With .NET 6, we’ve
seen some of the biggest leaps forward with the framework.
AOT (ahead-of-time) mode has been introduced, producing
huge performance improvements for Blazor WebAssembly
applications. The evolution of Xamarin, .NET MAUI, allows
Blazor to move out of the browser and be used to create
cross-platform desktop and mobile applications.
This book is the result of my journey with Blazor from that
first time watching Steve’s NDC Oslo presentation to
building production applications today. To date, I’ve
published over 75 blog posts about Blazor on my personal
blog and have written many for other publications. Blazor
also gave me a passion for public speaking, first at .NET
26. user groups and eventually at international conferences. I
even got to give a talk on Blazor at NDC Oslo in room 7, the
same room that Steve was in when he first presented his
experiment a few years earlier.
acknowledgments
This book has been one of the hardest projects of my life,
and while it has my name on the cover, it was only possible
with the help of many other people. I’d like to take this
opportunity to say a huge thank-you to those people.
First and foremost, I want to thank my wife, Robyn. You
have been my rock throughout the last year and a half. You
have had to deal with me at my worst during this time, but
your unwavering support and encouragement made me
believe that I could finish this. I will always be grateful for
that, and I love you very much.
I’d also like to thank my whole family for their support and
encouragement—especially my dad, who talked me out of
quitting at one point when I completely lost faith.
Next, I’d like to thank some amazing people at Manning
without whom this book would not exist. Brian Sawyer
recruited me, convinced me to write a proposal, and that I
could pull it off! Kristen Watterson, my developmental editor
for almost the entire project, helped shape the book into
what it is today. Toni Arritola stepped in at the eleventh
hour to get the book over the line. Andrew West, my
27. technical developmental editor, made sure my code made
sense and actually worked. Finally, Karthikeyarajan
Rajendran did a great job with the final technical proofread
of the book. Thanks also to the production team at Manning
for all their hard work in producing this book.
Also, a special thanks to all the reviewers for their
comments and feedback: Al Pezewski, Alberto Acerbis,
Ashwini Gupta, Bruno Sonnino, Grant Colley, Jason Hales,
Jeff Smith, Jim Wilson, John Rhodes, Kalyan Chanumolu,
Marcin Sęk, Mark Chalkley, Mike Ted, Pedro Seromenho,
Richard Michaels, Rohit Sharma, Ron Lease, Rui Ribeiro,
Steve Goodman, Tanya Wilke, Thomas Gueth, and Wayne
Mather—you made this a better book.
Finally, I’d like to thank Steve Sanderson, Daniel Roth, and
the whole ASP.NET Core team at Microsoft. You’ve created
something really special with Blazor, and it’s literally
changed my life. I’m now an author, international speaker,
and Microsoft MVP all because of Blazor. Thank you.
about this book
Blazor in Action has been written to take you from being a
beginner to being proficient and confident building Blazor
applications. Initially, the book covers high-level concepts
such as hosting models and components before drilling
down into specific features of the framework, such as
routing, forms and validation, and templated components.
28. To help imbed the various concepts and features, you’ll
build a real application—Blazing Trails—chapter by chapter.
By the end of the book, you’ll have a complete reference
app you can refer to anytime.
Who should read this book
This book is aimed at developers who have a basic
understanding of .NET, C#, and web technologies (HTML,
JavaScript, and CSS). If you’ve been building web
applications using Razor Pages or MVC, then the learning
curve will feel quite shallow. If you’ve been building apps
using ASP.NET Core Web APIs and a JavaScript framework
such as React, Vue.js, or Angular, then you’ll be in an even
better position.
How this book is organized: A road map
This book is organized into 11 chapters and 2 appendices.
Chapter 1 introduces Blazor, component-based UIs, and
hosting models. It covers what Blazor is and the
reasons why you might choose to use it, as well as how
components are a better way to build UIs and how
Blazor has embraced this approach. It also covers what
hosting models are and discusses the advantages and
tradeoffs they each have.
29. Chapter 2 begins the journey of building the Blazing
Trails application. Initially it covers choosing the right
project template for a new Blazor application, as well as
how to build and run it. Then it walks through the key
parts of a Blazor application. It concludes by talking
about file organization using feature folders and how to
write your first components.
Chapter 3 dives deeper into Blazor’s component model.
It discusses how to structure components, what life
cycle methods are and what order they execute in, and
how to work with parent and child components. It also
covers styling components and using CSS preprocessors
with Blazor.
Chapter 4 looks at client-side routing, showing how to
define page components and navigate between them. It
also tackles more advanced topics such as passing data
in the URL and navigating programmatically.
Chapter 5 is the first of two chapters covering forms
and validation. In this chapter, fundamentals such as
using Blazor’s built-in form components, validating user
input, and submitting data to a server are tackled.
Chapter 6 builds on the previous chapter, covering more
advanced topics such as creating custom form
components, working with files, and adapting a form to
handle editing existing data.
Chapter 7 explores how to make components more
reusable. It introduces templated components and how
they can be further enhanced using generics.
30. Chapter 8 shows how to use JavaScript interop to
integrate existing JavaScript libraries into a Blazor
application. It also covers techniques that allow C#
code to call into JavaScript code and JavaScript code to
call into C#.
Chapter 9 tackles securing Blazor applications by
showing how to integrate with an identity provider
called Auth0.
Chapter 10 looks at state management and implements
an in-memory state store. It tackles state store design
and how to store state using the browser’s local storage
APIs.
Chapter 11 covers testing components using the bUnit
testing framework. Five key scenarios are covered:
testing rendered markup, triggering event handlers
from test code, faking authentication and authorization,
emulating JavaScript interop, and testing multiple
components together.
Appendices A and B cover code refactoring required as
the example application grows. Appendix A covers
adding a ASP.NET Core Web API to the solution. If
you’re building the example app along with book,
appendix A should be completed between chapters 4
and 5. Appendix B walks through refactoring the rest of
the application to use the Web API introduced in
appendix A. Appendix B should be followed after
completing chapter 6 and before starting chapter 7.
31. About the code
This book contains many examples of source code, both in
numbered listings and in line with normal text. In both
cases, source code is formatted in a fixed-width font
like this to separate it from ordinary text. Sometimes
code is also in bold to highlight code that has changed from
previous steps in the chapter, such as when a new feature
adds to an existing line of code.
In many cases, the original source code has been
reformatted. We’ve added line breaks and reworked
indentation to accommodate the available page space in the
book. In rare cases, even this was not enough, and listings
include line-continuation markers (➥). Additionally,
comments in the source code have often been removed
from the listings when the code is described in the text.
Code annotations accompany many of the listings,
highlighting important concepts.
You can get executable snippets of code from the liveBook
(online) version of this book at
https://livebook.manning.com/book/blazor-in-action. Source code
is also available for chapters 2-11 in my GitHub repository
at https://github.com/chrissainty/blazor-in-action. The code
added in the two appendices are incorporated into the
chapters they precede.
All the code in this book was built using the .NET 6 SDK and
Visual Studio 2022. However, other tools such as Visual
32. Studio Code and the .NET CLI or JetBrains Rider will run the
code as well.
liveBook discussion forum
Purchase of Blazor in Action includes free access to
liveBook, Manning’s online reading platform. Using
liveBook’s exclusive discussion features, you can attach
comments to the book globally or to specific sections or
paragraphs. It’s a snap to make notes for yourself, ask and
answer technical questions, and receive help from the
author and other users. To access the forum, go to
https://livebook.manning.com/book/blazor-in-action/discussion.
You can also learn more about Manning’s forums and the
rules of conduct at https://livebook.manning.com/discussion.
Manning’s commitment to its readers is to provide a venue
where a meaningful dialogue between individual readers
and between readers and the author can take place. It is
not a commitment to any specific amount of participation on
the part of the author, whose contribution to the forum
remains voluntary (and unpaid). We suggest you try asking
the author some challenging questions lest his interest
stray! The forum and the archives of previous discussions
will be accessible from the publisher’s website as long as
the book is in print.
33. about the author
Chris Sainty is a web developer with over 17 years of
experience. He has been using Blazor since the first
experimental preview back in March 2018 and was one of
the first people to start blogging about it. Chris has
published over 75 blog posts on Blazor on his own blog,
while also writing guest posts for Visual Studio Magazine,
Progress Telerik, and Stack Overflow. He is also an active
open source developer and currently maintains some of the
34. most popular Blazor NuGet packages covering integration
with browser local storage APIs to UI components such as
modals and toasts. Away from the keyboard, Chris is a
seasoned conference speaker and has talked about Blazor
at events all over the world. These contributions have also
earned him the Microsoft MVP (Most Valuable Professional)
Award.
about the cover illustration
The figure on the cover of Blazor in Action is “Homme de
Oonolaska,” or “Oonolaska Man,” taken from a collection by
Jacques Grasset de Saint-Sauveur, published in 1797. Each
illustration is finely drawn and colored by hand.
In those days, it was easy to identify where people lived
and what their trade or station in life was just by their
dress. Manning celebrates the inventiveness and initiative of
the computer business with book covers based on the rich
diversity of regional culture centuries ago, brought back to
life by pictures from collections such as this one.
35. 1 Starting your Blazor journey
This chapter covers
Reasons to choose Blazor for your next application
Why components are a better way to build UIs
Hosting models for Blazor
We live in exciting times, as .NET developers’ lives have
never been better. We can create apps for any operating
system, be it Windows, Linux, iOS, Android, or macOS, and
of course, we can build amazing web-based applications with
ASP.NET MVC, Razor Pages, and Web API, which have
allowed us to create robust scalable and reliable systems for
years.
However, there has long been a missing piece to the puzzle.
One thing all of ASP.NET’s web solutions have in common is
that they are server based. We’ve never been able to
leverage the power of C# and .NET to write client-side web
applications; this has always been the domain of JavaScript
—but not anymore.
In this chapter, I’m going to introduce you to a revolutionary
client-side framework called Blazor. Built on web standards,
Blazor allows us to write rich, engaging user interfaces using
C# and .NET. We’ll explore how Blazor can make your
development process more efficient and raise your
productivity levels, especially if you’re using .NET on the
36. server as well. We’ll cover hosting models, an important
concept to understand when starting out with Blazor. Next,
we’ll begin to explore components and the benefits of using
them to build UIs. Finally, we’ll discuss the reasons why you
should consider Blazor for your next project.
1.1 Why choose Blazor for new
applications?
Arguably, the hardest part of starting a new project in recent
times has been selecting the tech stack—there are just so
many choices available. This is especially true in the
frontend world. We must pick a framework (Angular, React,
Vue.js), pick a language (TypeScript, CoffeeScript, Dart),
and pick a build tool (webpack, Parcel, Browserify). If a
team is new to this ecosystem, it can seem an almost
impossible task to try and work out which combination of
technologies will help make the project a success; it’s even
hard for teams with experience!
Let’s cover some of the top reasons for choosing Blazor for
your next project and how Blazor can help you avoid some
of the issues I’ve just mentioned.
37. C#, a modern and feature-rich language—Blazor is
powered by C#, the eighth most popular language,
according to the 2021 Stack Overflow Developer Survey
(http://mng.bz/p240). It’s powerful, easy to learn, and
versatile. While C# is an object-oriented language, it’s
adopting more and more abilities to enable a more
functional approach, if you prefer. Static typing helps
developers catch errors at build time, making the
development life cycle faster and more efficient. It’s also
been around for a long time, currently in its tenth
version. It’s stable, well designed, and well supported.
Great tooling—The .NET community has been fortunate
to have some amazing tooling. Visual Studio is an
extremely powerful, feature-rich, and extensible IDE
(integrated development environment). It’s also 100%
free for individuals, open source work, or non-enterprise
teams of up to five people. If you prefer something more
lightweight, then there is Visual Studio Code (VS Code),
one of the most popular code editors today. Both Visual
Studio and VS Code are available cross-platform. Visual
Studio is available on Windows and macOS, and VS Code
is available on Windows, macOS, and Linux. There is
also a great third-party IDE by JetBrains called Rider,
which is cross-platform running on Windows, macOS,
and Linux.
38. .NET Ecosystem—While many new frameworks need to
wait for an ecosystem to build up around them, Blazor
can tap into the existing .NET ecosystem. At the time of
writing, Blazor applications target .NET 6 and can, in
theory, use any compatible NuGet package. I say “in
theory,” as some packages perform actions that aren’t
allowed in a WebAssembly scenario, such as modifying
the filesystem.
Unopinionated—While other frameworks stipulate how
applications must be written, Blazor does not. There are
no preferred patterns or practices for Blazor
development; you can write applications using the ones
you’re familiar and comfortable with. If you like MVVM
(model-view-viewmodel), go for it. If you prefer using
Redux, have at it. The choice is yours.
Shallow learning curve—If you’re an existing .NET
developer, then the learning curve for Blazor is quite
shallow. Razor, C#, dependency injection, and project
structure will all look familiar to you, and with Blazor
being unopinionated around patterns, you can just use
what you’re familiar and productive with. All this means
you can focus on writing features more quickly, rather
than learning the framework.
39. Code sharing—If you’re using C# on the server, then
Blazor makes an excellent pairing. One of the most
frustrating problems with different client and server
languages is the inability to reuse code. Models or data
transfer objects (DTOs) must be duplicated between
server and client; they need to be kept updated, in sync.
This could be a manual process or automated using
some kind of code generation, but this is just another
thing to set up and maintain. With Blazor, everything is
C#. Any shared code can be placed in a common .NET
class library and shared easily between server and client.
Open source—As with many projects at Microsoft, Blazor
is fully open source and the code is freely available on
GitHub for you to browse, download, or fork your own
copy. The team works in the open and is guided by
developer requests and feedback. You can even
contribute if you wish.
1.2 Components, a better way to
build UI
Blazor, as with many modern frontend frameworks, uses the
concept of components to build the UI. Everything is a
component—pages, parts of a page, layouts. There are
various types of components in Blazor, as well as multiple
ways to design them, all of which will be explored in future
chapters. But learning to think in terms of components is
essential for writing Blazor applications.
40. 1.2.1 What is a component?
Think of a component as a building block. You put these
building blocks together to form your application. These
building blocks can be as big or as small as you decide;
however, building an entire UI as a single component isn’t a
good idea. Components really show their benefit when used
as a way to divide up logical areas of a UI. Let’s look at an
example of a user interface structured as components
(figure 1.1).
Figure 1.1 Example of a layout divided into components
Each area of the interface is a component, and each one has
a certain responsibility. You may also notice that there is a
hierarchy forming. The layout component sits at the top of
41. the tree; the menu, header, home page, and footer are all
child components of the layout component. These child
components could, and probably would, have child
components of their own. For example, the header
component could contain a logo component and a search
component (figure 1.2).
Figure 1.2 Example of nesting components to form a component tree
1.2.2 The benefits of a component-based UI
Many UIs have repeating elements in them. A great
advantage to using components is that you can define an
element in a component and then reuse the component
wher-ever the element repeats. This can drastically cut down
on the amount of repeated code in an application. It also
makes the maintainability of the application much better—if
the design of that element changes, you need only to update
it in a single place.
To cater to more advanced scenarios, components can define
their own APIs, allowing data and events to be passed in and
out. Imagine a line-of-business application. It’s probably
safe to assume that within that app there are many places
data is displayed in table format. One approach is to create
each table as its own component; however, this means we
42. would end up with a lot of components that display data in a
table. A better approach is to define a single component that
takes in a data set as a parameter and then displays it in a
table. Now we have a single component for displaying data
in a table that we can reuse all over the application. We can
also add features to this component, such as sorting or
paging. As we do, this functionality is automatically available
to all the tables in the application, as they are all reusing the
same component.
While often self-contained, it’s possible to have components
work together to create a more complex UI. For example,
let’s take the data table scenario we just talked about, which
could be a single component but could potentially be quite
large. Another approach is to divide it into several smaller
components, each performing a certain job. We could have a
table header component, a table body component, and even
a table cell component. Each of these components is
performing a specific job, but they are still part of the overall
table component.
1.2.3 Anatomy of a Blazor component
Now that we have a better idea of what components are in a
general sense, let’s look at an example of a component in
Blazor. For this, we’ll grab a component from the Blazor
project template. Figure 1.3 shows an example of a
component from Blazor’s standard project template,
Counter.razor.
43. Figure 1.3 The sections of a component in Blazor
This particular component is known as a routable
component, as it has a page directive declared at the top.
Routable components are essentially a page in the
application. When the user navigates to the /counter route
in the application, this component will be loaded by the
Blazor router. It displays a simple counter with a button, and
when the user clicks the button, the count is incremented by
one and the new value displayed to the user.
While understanding the code isn’t important at this point,
we can understand the structure of the component. Figure
1.3 is divided up into three sections; each has a certain
responsibility.
44. Section 1—Used to define directives, add using
statements, inject dependencies, or any other general
configuration that applies to the whole component.
Section 2—Defines the markup of the component; this is
written using the Razor language, a mix of C# and
HTML. Here we define the visual elements that make up
the component.
Section 3—The code block. This is used to define the
logic of the component. It is possible to write any valid
C# code into this section. You can define fields,
properties, or even entire classes if you wish.
We’ll be covering components in much greater detail
throughout the rest of this book, so we’ll leave it there for
now. But this has given you a taste of what a component in
Blazor looks like and how it is composed.
1.3 Blazor, a platform for building
modern UIs with C#
Blazor is a fully featured framework for building modern
client-side applications using the power of C# and .NET. This
allows developers to build engaging applications that work
across nearly any platform, including web, mobile, and
desktop.
Blazor is an alternative to JavaScript frameworks and
libraries such as Angular, Vue.js, and React. If you’ve had
experience working with any of these, then you’ll probably
46. “You forget, sir, that Mrs. Marjoy, with her quince-jelly eyes and
her peony complexion, considers herself the one fascinating woman
in Saltire. When I tell you that she has been squinting at us
venomously through her spectacles you should be able to foresee
the future.”
“Need you dread the lady?”
“My dear Gabriel, Mrs. Marjoy will relate to all her friends how
bored you were by me at your father’s dinner-table. Remember that
I am still in the marriage market and must defend myself against the
calumnies of my fellow-shes.”
“Hence my responsibility.”
“To aid me in maintaining an eligible exterior.”
Blanche Gusset, Gabriel’s neighbor, was a pert, plump, and
slangy young person, very rubicund and very pushful. Her vitality
was phenomenal, her vigor Amazonian. She feared neither sun nor
freckles, frumps nor fashions. Moreover, she was the one woman in
the neighborhood who could attack and rout the redoubtable Mrs.
Marjoy, that most Christian Medusa, who attended the eucharist
fasting and concocted malignities an hour later over the breakfast-
table.
Her sister Ophelia, who faced her over the silver and the flowers,
proffered a contrast that was peculiar and piquant. The elder sister,
a tall and supersensuous blonde, listened with languid frigidity to the
banalities of the Reverend Jacob Mince. She was a large woman with
eyes of a brilliant blue, supercilious yet pleasurable lips, and a
Circassian countenance. A chain of amethysts glittered over the
fulness of her broad bosom. Her fair hair was coiled in masses above
her forehead, overshadowing her eyes and throwing into evidence
the somewhat heavy sensuousness of her face. She talked little, and
with an air of luxurious slothfulness that seemed in keeping with her
expression of delectable and Lilith-like torpor.
Above the blaze of hot-house flowers the eyes of this complacent
beauty met those of Gabriel Strong. The pair had seen much of each
other that winter in an incidental and desultory fashion. Castle
Gabingly had been something of a hermitage, and a Greek-faced
youth such as Gabriel had more vivid interest for the lady Ophelia
47. than monotonous novels and the society of Lord Gerald her father.
Gabriel Strong had fine eyes, a quick tongue, and a certain cynical
quaintness in his attitude towards women.
Miss Blanche Gusset reverted to the silent being at her elbow.
“Are you asleep yet, Moses?”
“Why a Semitic title?”
“I often call people by the name that slips first off my tongue.”
“A dangerous habit.”
“Explain.”
“For instance, you might greet Mr. Mince as Beelzebub.”
“And not a bad thrust either. Gabriel, you are waking up. Please
continue to preserve me from Mrs. Marjoy.”
“Ophelia is looking well to-night,” said the man.
Miss Blanche Gusset’s brown eyes sparkled. She popped an olive
between her lips and descended once more to personal topics.
“What an arrant humbug you are,” she said. “If I had Mrs.
Marjoy’s temper I should conceive some diabolical revenge. Must I
apologize for not being my sister?”
“On the contrary, I am excellently placed.”
“An ambiguous compliment, my dear archangel.”
“Flattery is always ambiguous, Miss Gusset. I feel in a
sympathetic mood. Please tell me how those fox cubs of yours are
progressing.”
His neighbor retorted with an ironical twinkle.
“You may continue your meditations,” she said; “I shall reserve
my remarks on cubs till Mrs. Marjoy begins gabbling in the drawing-
room about that dear child of hers.”
When the more spiritual element had departed Gabriel
discovered himself partnered by that inestimable worthy Jacob
Mince. The churchman, unctuously freighted, smacked his lips over a
fat Havana. Mr. Mince was a tall and complacent person, with a bald
pate, a watery eye, and a receding chin. He was a species of petty
pope in his own parish, dogmatizing over pond and pigsty, ploughed
fields, and the village pump. There was no imaginative or expansive
breadth in Mr. Mince’s opinions. Yet he was nothing of an ascetic,
and was wholly Christian towards his own stomach.
48. Gabriel, by way of bestirring the churchman’s ardor, referred to
certain political questions that were agitating the country. Sectarian
squabbles amused Gabriel as a philosopher; they did not inspire him
as a partisan. Dissent was an infallible red rag wherewith to inspire
Mr. Mince’s temper. Like many sectarians, he was utterly intolerant of
adverse criticism.
“My dear sir,” he said, in his consequential and litanical tenor,
“you will hardly credit it, but I am being bothered most abominably
in my own village by a certain vagrant tub-thumper, who has had the
insolence to hold open-air services under my very nose.”
Gabriel professed a somewhat cynical sympathy.
“Such a reflection on your ministrations,” he observed; “as
though you neglected your parish! I suppose the man is an
agnostic.”
Mr. Mince frowned and puffed irritably at his cigar. He did not
appreciate such suggestive sympathy.
“Not a bit of it,” he retorted; “the fellow is a mere ignorant
mechanic who comes over every Sunday from Rilchester to instruct
ignorant people in Christian ethics. The fellow has even had the
insolence to choose the very hour of even-song for his bawling. I
was discussing the matter with your father before dinner.”
Apparently Mr. Mince would have preferred rank infidelity in such
a rival to the honest profession of Christian principles. In such
competition a fellow-believer was more nauseous to him than the
blackest atheist who ever blasphemed the Trinity. There was a
certain element of personal glory in combating the malignities of a
spiritual opponent. Mr. Mince desired to propound the Bible to his
own credit.
“I suppose it does not matter vastly,” said Gabriel, with tactless
magnanimity, “what a man is so long as he preaches Christ in the
right spirit.”
Mr. Mince elevated his eyebrows.
“Not matter?”
“No.”
“My dear fellow, you do not realize the pressing peril of this
astounding phenomenon of dissent. It is the most calamitous
49. development arising from the abuse of this modern spirit of
socialism.”
The topic interested Gabriel enough to inspire in him a mild
antagonism.
“The very movement would suggest to me,” he said, “that the
laboring classes need a living exposition of the creed and that the
Church has proved inadequate to the occasion. Am I to understand
that you consider a university education essential to those who
desire to be the religious instructors of others?”
“Most certainly education is essential.”
“That depends, sir, does it not, upon what people call education.
Classics and theology are out of date; science and the study of
human nature are to the fore.”
Mr. Mince knocked the ash from his cigar and seemed displeased.
“What is science, sir,” he said, “but a blind man grubbing in a
ditch. There is no hope in science. You must really rely on me as an
expert in these matters. More experience is granted to those whose
studies have extended through many years. We churchmen are
specialists on religious education.”
Gabriel, like many enlightened mortals, demurred at subjecting
reason to the dogmas of a clique. He preferred to drink of the cup of
spirituality without receiving it from the hands of another. He did not
believe that the Light of the World descended only upon those who
knelt in a particular pew.
“I have a shrewd notion,” he said to Mr. Mince, “that these poor,
as we call them, often come nearer the elemental truth than
wiseacres steeped in theological learning. The nursing of a sick
neighbor is a better thing than the discovering of twenty
metaphorical meanings in a single text. A man is wise in proportion
to the breadth and sincerity of his beliefs. Nor can I see that it
requires much erudition to expound faithfully the philosophy
contained in the Sermon on the Mount.”
“That does not satisfy the question,” retorted the clergyman. “Ask
Dr. Marjoy what he thinks of quacks who profess to practise
medicine. The analogy is admirable.”
“There—I cannot agree with you.”
50. Mr. Mince withdrew behind his ecclesiastical dignity.
“You are young yet, Mr. Strong,” he said, “and young men are
zealots, youth itself too Utopian. Let me advise you not to take your
notions from silly novels and superficial magazines. At all events, sir,
I caught William Blunt, my gardener, attending one of these outdoor
meetings. The man had been my gardener ten years.”
“I suppose you reprimanded him.”
Mr. Mince’s righteous anger kindled.
“Reprimand him, by Jove! I pointed out to the fellow the
outrageous ingratitude of his conduct, and discharged him promptly
from my service.”
“A decisive protest!”
“A well-merited lesson.”
Gabriel smiled at the blooms of a pink azalea.
“Possibly this apostle preaches powerfully,” he said.
“The usual jargon, I believe.”
“I feel inspired to hear him myself.”
Mr. Mince removed his cigar from between his lips, and stared
open-mouthed.
“My dear sir, as a gentleman, and as a member of my
congregation, you will not countenance such an impostor within the
bounds of my parish.”
Gabriel laughed good-naturedly.
“It would be a great breach of etiquette, I suppose,” he said.
“Hallo, I see the others are rising. I think it is time we joined the
ladies.”
In the drawing-room Judith was at the piano, accompanying
herself to the quaint measure of an old song. After the gentleman
had entered her place was usurped by Miss Blanche Gusset, who
dashed volubly into the strenuous sentiment of a plantation ditty. In
a panelled “cosey corner” Mrs. Marjoy and Mrs. Mince sat in
neighborly isolation, comparing feminine criticisms. Mrs. Marjoy was
a lady who possessed no single talent herself and always sneered at
the accomplishments of others.
Gabriel surrendered himself to Ophelia Gusset. She was seated
alone on a sofa to the left of the fire. Ophelia was not a woman’s
51. woman in the social sense; her virtues were egotistical and
unexpansive. She found men more appreciative, less critical, more
sympathetic.
“What selfish beings you men are,” she observed.
“Why such cynicism?”
“You abandon us for tobacco. I am sure you have been talking
for forty minutes.”
“Politics proved powerful.”
“I did not know you were a politician.”
“No, I am not patriotic with my tongue. Mr. Mince and I had an
argument on street-preaching. How easy it is to offend some
people.”
Gabriel seated himself on the sofa beside Ophelia Gusset.
She was shading her face from the fire with her fan, her
shoulders gleaming white through a web of lace. The red flowers at
her breast shone like stars to pilot desire. A mesmeric atmosphere
seemed to encircle her; her large eyes were languorous and alluring.
“You seem in queenly isolation,” said the man, noting almost
unconsciously the white sweep of her shoulders. She smiled at him,
and seemed none too sorry to surrender her solitude into his
keeping.
“Elderly ladies are really too trying,” she said to him. “I never met
such extraordinary rustics as Saltire produces.”
“Mrs. Mince and Mrs. Marjoy have been conversing for your
benefit? A lecture on infant underclothing or the darning of
stockings?”
“Far worse, I assure you. Missionary incidents from The Reaper;
a dissertation on pickling onions; certain remarks from Mr. Mince’s
last sermon.”
“And Mrs. Marjoy?”
“What does Mrs. Marjoy usually talk about?”
“Herself and her children and the vices of her friends.”
“Dear creature! Blanche had a thrust at her before you joined
us.”
“Your sister is a brave woman.”
52. “It was really quite epigrammatic. Blanche declared that a spoiled
child was like a spinster’s poodle—an animal that always had the
best chair, clawed the visitor’s clothes, and yelped eternally for cake.”
“Excellent! excellent!”
“Mrs. Marjoy glared.”
“Heaven be thanked! I am not the doctor.”
They wandered out into the conservatory together, where tulips,
red, purple, and gold, blazoned the benches. Azaleas stood starred
with color amid the ascetic snow of lilies. Bowls of mignonette and
violet dowered the air with odors. Many rich plants were brilliant
with bloom.
The girl drew her bare arm gently from Gabriel’s. Her movements
were sinuous and graceful, mesmeric as a Circe’s. He marked the
rare curves of her neck and shoulders, her delicate coloring, the
golden profusion of her luxurious hair. The vision of the girl bathing
in the pool still burned and glimmered in his brain. He was
susceptible to sensations for the moment, too prone to pander to
the sensuous in art.
“Mrs. Marjoy is a great gardener,” he said, reverting to mundane
malice to restrain his thoughts.
“If I were Hamlet’s Ophelia,” she answered him, “I should give
her a posy of nettles.”
The man laughed and touched her hand.
“And to me?”
She pouted out her lips with a mischievous stare.
“Laurel leaves, perhaps, to wear when you are laureate.”
“Sarcasm.”
“Retort at your leisure.”
The sound of music came to them, for Judith was playing one of
Schubert’s songs. Gabriel thrust his hand into a bowl of violets and
proffered them in his palm.
“To be sure, I am modest enough,” she said, setting several in
her bosom.
53. A
IV
ZURE and white shone the liveries of heaven. The sun, that
gold-tabarded trumpeter, had pealed out the brazen clarion-cry
of summer. The pavilions were spread in the woods. The fields
bristled their myriad spears, still green and virgin with desirous sap.
Rose had clasped rose. The meadows had unfurled their cloth of
gold. The red may had bloomed and the lilac had kissed the yew.
A punctilious regularity ordered the daily details of the domestic
régime. No stranger ever ventured through the rusty gates to disturb
the sordid asceticism of Zeus Gildersedge’s privacy. A neighborly
anathema had long ago gone forth against the house. Nor had its
master troubled to appease the orthodox wrath of a society that he
despised. There is a species of vanity of disfavor, and Zeus
Gildersedge was a man who could chuckle over public obloquy with
a heathenish pride.
The miser sat in the garden under the shadow of two yews,
whose sculptured boughs arched a natural recess. A table stood
before him bearing claret, a phial of opium, a ledger, and a jar of
tobacco. The grass grew in feathery rankness wellnigh to Zeus
Gildersedge’s knees. Foxgloves purpled the lawns. Roses ran
adventurously in red riot over a rotting trellis that was half
smothered in the grass. It was a tranquil refuge enough, full of
greenness and the calm, clamorless quiet of the trees.
Zeus Gildersedge set his pipe aside, gulped down half a glass of
claret, covered his face with a red handkerchief, and prepared for
sleep. Every afternoon between two and six he would doze away the
hours, his brain drugged to a sensuous slumber. Even for this miser
opulent visions gleamed through the portals of sleep. His dreams
partook of opiated poetry. Mountains of gold poured torrents of
jacinth, chrysolite, and sardonyx into an emerald sea. Great trees
bore gems for fruit, purple, vermilion, and green. Fountains tossed
54. diamonds like spray to a glittering zenith. Each flower of the field
had a pearl or a ruby betwixt its lips.
A streak of scarlet showed suddenly between the trees. A
woman’s figure threaded through the green, passing the lawns knee-
deep in grass, brushing the foxgloves with the swing of her coarse,
black skirt. The loose strings of her lilac sun-bonnet trailed upon her
shoulders. She moved slouchingly, yet with a certain loose-jointed
vigor that suggested strength.
Coming to the fringe of the lawn where an old dial stood in the
sun, she scanned the stretch of grass under a coarse, red hand.
Zeus Gildersedge was asleep with his handkerchief over his eyes.
She moved silently towards the yews and stood by the table,
watching with a grin the man dozing in the chair. As he snored on
obliviously she reached for the claret jug, put it to her lips, took a
long draught, wiped her mouth on the back of her hand. She
returned the jug noiselessly to its place, plucked a long spear of
grass, and tickled the sleeping man’s chin.
Zeus Gildersedge grunted, smote the air, and clawed the
handkerchief from his face. He stared about him, saw Rebecca
laughing by the table, and promptly swore at her.
“What the devil do you want now?”
“Tuppence.”
“What for?”
“The tinker.”
“Let him wait for it.”
“He ain’t here yet; he’ll call this evening with a saucepan he’s
been soldering. Thought I’d get the money while there was a chance
of you being sober.”
Zeus Gildersedge straightened in his chair, fumbled in his pocket,
and produced two coins. He laid them on the table with a
melancholy and grudging deliberation as though he were disbursing
thousands.
“Damn your insolence,” he said.
“Be civil yourself, master.”
The man’s eyes scanned the glass jug. He gripped it with one
claw of a hand and stared at the woman blurred in the sunlight.
55. “You’ve been at the claret.”
The girl laughed a loud, quaking laugh of coarse merriment. She
jerked forward, subsided on the man’s knees, poked her face into
his.
“Taste my breath—now.”
“Get up with you.”
“Sha’n’t.”
He pushed her away from him, and she slid to the grass at his
feet and lay there giggling, with her sun-bonnet fallen back from her
hair. Zeus Gildersedge eyed her with mingled approbation and
disfavor. He had bartered his dignity long ago, for the woman had
made him her equal in dragging him to her own level. They
understood each other in a coarse, abusive fashion, and were
comrades of a common cult.
“Where’s Joan?” said the man, fingering his chin, while his
colorless eyes shone out from his bloodless face.
“Don’t know. ’Tain’t no business of mine, though you let her gad
over the country like a gypsy. You’re a fool, Zeus Gildersedge. Nice
sort of father you make.”
“Joan can look after herself.”
“So can every woman till she lights on a man.”
Zeus Gildersedge shifted in his chair.
“Balderdash!” he said, with tightened lips. “The girl has pride
enough to choke most men. She’s no bib-and-tucker baby.”
“A woman’s a woman, bib or no bib,” retorted the servant.
Zeus Gildersedge took ten drops of opium in a tumbler of claret,
frowning as he sipped it down.
“You’re a nice bit of goods to lecture me on education.”
Rebecca plucked up a handful of grass and threw it into the
man’s lap.
“There’s hay for you,” she said, grimacing. “Miss Joan’s worth
twenty of me and you. Pity you don’t treat her better. I wouldn’t
stand all the grubbing she stands—no, not for nothing. I wouldn’t be
your daughter, neither; a fine girl like she is shut up with an old goat
to feed on thistles in a tumble-down shanty. You’re too mean to have
a daughter. There’s the truth for you.”
56. She laughed a reckless, barbaric expression of superabundant
vigor, a challenge to the thin, sallow being squatting under the yews.
Zeus Gildersedge regarded her with his small, calculating eyes. A
slight color had crept into his cheeks. The fingers of his right hand
fidgeted the buttons of his coat.
“I should like to know why I don’t pack you out of my house with
an hour’s notice,” he observed, in tones that were whimsically
contemplative.
The girl’s eyes glistened; her full lips parted over her large,
strong teeth. She was handsome in a coarse, physical fashion. Her
hair was black as a raven’s wing, her cheeks red as sun-mellowed
apples, her figure profusely Rubenesque in outline. She made a
broad furrow in the tall grass where she lay, supporting herself on
one arm, with the sunlight glancing on her hair.
“Say the word—I’m off,” she said.
“Pack your box, then.”
“Six months’ wages.”
“And a deuced fine character.”
They both laughed. The girl gave a pouting smile, reached up,
and gripped the man’s knee. Zeus Gildersedge stared into her eyes
with a glance that was half critical, half human. They remained so
for half a minute before the man swore and dropped back into his
chair with a contemptuous chuckle.
“Threescore years and yet a fool,” he said.
“The carrier will pass at eight.”
“Shut up.”
The girl wriggled nearer in the grass, looking in the man’s face
with a mischievous simper.
“I want two new dresses, and—”
“You bet.”
“I’m going to Rilchester market-day.”
“Who’s to stop you?”
“And in that little cash-box in the cupboard—”
“Hist!”
“What’s wrong?”
“Get up; she’s coming.”
57. “Who?”
“Joan.”
The girl Rebecca bit her lip, scrambled up, and started away
some paces.
“I’ll give the tinker tuppence for mending that pan,” she said,
with an intentional strenuousness. “Mutton and potatoes at eight,
sharp.”
Joan Gildersedge drew near under the snow-starred vaults of a
tall acacia. Her hair flashed about her shoulders magic gold; her face
shone white under the dense, green boughs. A pillar of pure
womanliness, pearl-bright and lovely, she moved through the deep
ecstasy of the summer silence. Her eyes shone large and lucid as
fine glass. An infinite wistfulness dwelt upon her mouth like
moonlight on a rose. Divinely human, radiant with an
incomprehensible mystery of soul, she stood before her father.
Zeus Gildersedge regarded her with a species of unwilling awe.
He was man enough to realize the strange charm of this rare being
who called him father. To him she was in large measure
unintelligible, a denizen of an atmosphere impenetrable to his
meagre, goatish vision. Her very unapproachableness, her serene
temper, often created in him a rough and petulant antagonism, a
strong sense of inferiority that nudged his starved and decrepit
pride. She was of him, yet not his, an elusive and scintillant soul,
who suffered his interdictions and his barbarisms in silence, retaining
beyond his ken a species of intangible freedom that defied his
power.
“You’re late,” quoth the man in the chair, filling a long, clay pipe
and preparing to smoke.
“I had forgotten how the hours passed.”
Zeus Gildersedge stretched himself in his chair and yawned. He
habitually felt ill at ease in his daughter’s presence. She had a queer
knack of upsetting the equanimity of his avarice and jarring the
mean structure he called his soul. They had nothing in common.
Even on the tritest subjects they were out of sympathy.
“You seem to be away a good deal,” said the man, remembering
the words Rebecca had thrown up at him from the grass.
58. “Am I?”
“What do you do with yourself all day?”
“Wander in the woods, watch the birds, collect flowers, bathe in
the sea.”
“Bathe—do you!”
“Every day.”
“Beginning to find your father a dull dog, eh? We don’t do a vast
amount of entertaining. Rather a quiet place this,” and he laughed.
Joan dangled her hat by the strings and watched her father with
a supreme and unconscious gravity. She was ever attempting to
understand his mental condition; she had never yet succeeded.
“I often wonder why we have no friends,” she said.
Zeus Gildersedge enveloped himself in an atmosphere of smoke.
He distrusted in particular the developing instincts of this queen,
realizing that she had little cause to recompense his authority with
any great degree of gratitude. He had begotten and reared her,
given her the fundamental necessities of life, but little else. She
never displayed discontent in his presence, never reproached his
niggard régime. Zeus Gildersedge did not expect love from her,
seeing that he was barren of that sentiment himself.
“Friendship is an expensive commodity,” he observed, with a
sullen yet hypocritical earnestness. “We have to pay for affection in
this world; one can get plenty of sympathy by giving dinner-parties.
Spend money and people will welcome you. Poverty means isolation
and contempt.”
The girl’s eyes were still fixed imperturbably upon his face. She
seemed to weigh his words upon the balance of a virgin intuition
and to find them inadequate.
“Are we so poor?” she asked.
Zeus Gildersedge grunted.
“Pretty much so.”
“You find it a miserable experience?”
“You think so, eh?”
“If loneliness and poverty go together, you must be very poor.”
“You’re growing too clever with that tongue of yours.”
59. Joan leaned against the trunk of the acacia and smiled at the
clouds. A cataract of golden light poured through the delicate
foliage, smiting the shadowy grass with green splendor, painting
quivering fleur-de-lis upon the girl’s dark dress.
“Father,” she said, gently enough, “I often wonder what you live
for.”
The man in the chair bit his pipe-stem and frowned.
“You do, do you!”
“I am young, you are old. What pleasures can you find in life?”
Zeus Gildersedge eyed her keenly under his drooping lids.
“What do most men live for?” he asked her.
“How should I know?” she answered him.
“Money, gold bags, beer, and bed. You will understand it all well
enough some day.”
She looked at him with her large, gray eyes, calm and
incredulous.
“And what, then, of death,” she asked, “if we live for nothing
more than this?”
The man straightened in his chair.
“What’s that?”
“Death.”
“What’s death to you?”
“The falling of leaves and a silence as of snow under a winter
sky. I often think of death; nor is it strange to me. Do you fear the
grave?”
“Stop this nonsense,” said the man, with some symptoms of
rebellion.
“Are you happy?”
Zeus Gildersedge wriggled in his chair.
“When I want your sympathy I’ll ask for it,” he said. “You’re a
little too forward for your years, my dear. Don’t worry your head
about my future. Keep your sentimentalities for the birds and the
bees and the twaddling rubbish you read in books. Damn sentiment.
Supper at eight.”
When the girl had gone Zeus Gildersedge clutched his ledger to
him, his brows knitted into a scowl of thought. His hands strained at
60. the book with a tremulous intensity, while his eyes stared into space.
Overhead a blackbird was pouring a deep torrent of song to join the
sunlight. A slight breeze made the boughs oracular with sudden
mysterious mutterings. The beneficent eyes of the universe seemed
to watch with a scornful pity the vague dreads of infidelity and
greed.
As though waking from some unflattering dream, Zeus
Gildersedge’s hands relaxed and suffered the book to slip slowly into
his lap. He breathed an oath under his breath, gulped down a
mouthful of claret, and lay back in his chair chuckling.
61. "I
V
DETEST prigs,” said Mrs. Marjoy, as her hands flickered over the
tea-tray in the drawing-room of The Hermitage. “And of that
tribe commend me to young Strong as the prince of the sect.”
Mrs. Marjoy was one of those irreproachably vulgar persons
whose mission in life appears to be the distilling of spiritual nostrums
for the consciences of their neighbors. She was a born critic, a
mercurial being ingrained with prejudice and dowered with an
inordinate self-esteem. She had run “to tongue” in a remarkable
degree; moreover, she scanned the world through the prisms of a
none too generous philosophy.
“My dear,” quoth Mrs. Mince, balancing a large slab of cake in her
saucer, “young people are naturally irreverent in these days. You
would hardly believe me, but Gabriel Strong, a mere boy, had the
impudence to argue with my husband on religious matters after
dinner the other evening. Poor, dear Jacob came home quite upset.”
Mrs. Marjoy’s chair creaked. She was a lady who seemed to
extract discords even from things inanimate. The harmonium in the
church school-room was her most eloquent disciple.
“What had the young cub to say?”
“Well, my dear, he contested that he could see no harm in that
ignorant nonconformist preaching at the village cross on Sundays.
He snubbed poor, dear Jacob most abruptly, and declared that he
should go and hear the fellow preach. Think of that—to the vicar of
a parish!”
Mrs. Marjoy sniffed, a habit of hers when she wished to be
expressive.
“Abominable!”
“Such bad taste!”
“Intellectual young men are always objectionable. Strong, Junior,
always strikes me as a dissolute person. What do you think, my
62. dear?”
Mrs. Mince cogitated over her cake. She was not exactly
conversant with the characteristics of dissolute young men, but as
the vicaress of Saltire she aimed at claiming a mild versatility in the
technicalities of vice and virtue.
“Jacob declares,” she said, retreating upon an infallible authority,
“that he has never met a young fellow so irreverently arrogant
towards the opinions of his elders. And Jacob is such a man of the
world!”
“Exactly,” said Mrs. Marjoy, with a tinge of irony. “It is so ill-bred
to argue with people more experienced than one’s self.”
The Cassandra of the tray solaced herself with a second cup of
anæmic tea. She had an irritable habit of shrugging her shoulders as
though troubled—science forgive the expression!—with a chronic
urticaria of the brain. Irritability, indeed, was her enshrouding
atmosphere.
“As for those Gusset girls—” she began.
Mrs. Mince held up a horror-stricken hand.
“Such underbred young women. Why, I remember one of them
coming to church in a red dress on Good Friday. The way they get
up, too!”
Mrs. Marjoy plunged into detail with the fervor of a scientist.
“I told that woman Ophelia once,” she observed, “that I
wondered how she could go into a public place with a low-cut blouse
and no collar.”
“Really!” said Mrs. Mince, rapturously.
“She was rude, as usual. Said some necks did need covering up.
It is no use giving such girls advice.”
“Absolutely useless,” observed Mrs. Mince.
The teapot was regarnished and two more slices of cake
delivered to martyrdom. Mrs. Marjoy leaned back in her creaking
chair and indulged in philosophies.
“The aristocracy is rotten to the core,” she remarked, with
comprehensive complacency. “The broad-minded and educated
middle-class forms the backbone of the country. Any third-rate
actress could teach many duchesses manners.”
63. “My dear, your opinions are so full of commonsense.”
“I am always outspoken.”
“An excellent habit.”
“I flatter myself that I am a lady, Mrs. Mince, and I like to give
people my frank opinion. I never speak wantonly and unjustly of
absent neighbors. But as for those simpering and forward young
Gussets, well—”
A knock at the door cut short Mrs. Marjoy’s unprejudiced diatribe.
A servant entered with a letter on a salver and stood waiting. Mrs.
Marjoy slit the envelope with the handle of a teaspoon, perused the
contents of the note, flicked it away contemptuously into the grate.
“No answer.”
The girl disappeared. The doctor’s wife flounced back in her chair,
shrugged her shoulders viciously, and surveyed her friend irritably
through her spectacles.
“From those Mallabys,” she said.
“Of Catford?”
“People I never could stand. An invitation to their garden-party—
such garden-parties, too! The ices made me ill there last summer;
James was about all night giving me chlorodyne. Let me see, what
were we talking about?”
“The Gussets,” crowed Mrs. Mince.
“Oh yes, those most immoral women. Really, my dear, I wonder
John Strong lets his daughter associate with such people, but of
course everybody knows that John Strong is a snob and a toady. The
way the girl Ophelia flirts with that young Gabriel is absolutely
indecent. They are always about fishing together, now, down in the
Mallan. Most improper! You should hear James’s views on society
women. I’ve just been reading that awful Gosling case in the
newspapers.”
Mrs. Mince’s interest revived ostensibly. She brushed sundry
crumbs from her lap and rearranged her cushions.
“A most deplorable case,” she said, with Christian unction.
“How a man can run away from his wife passes my
comprehension,” said the physician’s mate. “I really do not know
64. what we are coming to in these days, what with women like the
Gussets taking the lead in society.”
Mrs. Mince sighed an orthodox and Protestant sigh.
“The young men are so different, too,” she said.
“They want discipline, my dear, what with their absurd notions of
independence and their revolutionary ideas about the Church and
religion. We have had three assistants in a year—such boors! There
was Snooks, who fell in love with little Miss Ginge; I soon put my
foot on that. Then there was Lily, who talked theosophy and smoked
such pipes in the surgery that the whole house stunk. I had to forbid
smoking, and Lily left. The man we have now is such a glutton;
always has two helpings at dinner and eats half a cake at tea.”
“I never see him at church,” said Mrs. Mince, grievedly.
“Young men never go to church in these days,” quoth Mrs.
Marjoy, with an irascible twist of her mouth. “They are too
enlightened, you know. I told young Bailey, the man we had last
year, that he ought to be ashamed of himself setting the villagers
such a bad example. He had the insolence to say that from his own
observations church-going did not improve people’s tempers. Of
course, I had to get James to give him a month’s notice.”
“Young men must be a great worry in a house,” said Mrs. Mince,
sympathetically.
Mrs. Marjoy twitched her shoulders.
“They are so abominably selfish,” she said.
The doctor appeared at this period of the conversation, a kindly
and easy-going Briton, artificially cheery and optimistic. He shook
hands with Mrs. Mince and sat down on the extreme edge of a chair.
His wife gave him the dregs of the teapot, and remarked that he was
late.
“Met young Strong in the village and had a chat,” he ventured, by
way of justification. “Bright young chap; a little too bookish, though.”
Mrs. Marjoy sniffed.
“The rising generation reads too much,” she said. “Do you
remember Bailey, who was always reading novels on a Sunday till I
gave him a talking to and he left?”
65. Mr. Marjoy sipped his tea and sighed. He was a suppressed soul,
a Prometheus bound upon the rock of matrimony.
“Bailey was not half a bad chap,” he said, meekly.
Mrs. Marjoy ignored the remark.
“What’s Grimes doing?” she asked.
“He has been seeing folk all the afternoon.”
“James, I believe that fellow’s running after that Ginge girl like
Snooks did. I won’t have it, mind. I can never catch Grimes in the
surgery. What the man does with himself I can’t think.”
“Grimes is all right,” said the doctor. “I must say I like young
Strong.”
“A prig, my dear—an arrant prig.”
The doctor did not contradict her. He had grown wise in season
and took his chastenings with reverent patience. It was not his
ambition to out-talk his wife.
“You take my word for it,” said Mrs. Marjoy, with acrimony, “there
will be a scandal here soon. That young Strong is a most dissolute
youth; and as for the Gusset girl—well, I will be charitable and
conceal my thoughts. I always try to say kind things of people, when
they will let me do so by leading decent and respectable lives.”
“My dear,” said Mrs. Mince, “you are a model of tact. By-the-way,
I hear the church-bell. I must attend vespers. Are you coming to
hear Jacob preach?”
“I will get my prayer-book,” said the doctor’s dame.
66. P
VI
ERILOUS and fair as Calypso is the imagination to the mind of
man. A strong soul girds the elf in tender subjection. Like wine,
the imagination fires the senses; they are saffron spray bubbling
in an iris bowl, red poppies smothered in an ecstasy of green, stars,
diamonds, and the long glimmer of a moonlit sea. Odors beat upon
the imaginative brain; colors burn its vision. Like a siren’s voice falls
the chant of the wind through the rose-red halls of summer. To the
poet the world leaps like a young lover into the bosom of the sunset.
Seas clamor and the stars tune their strings.
Gabriel was an imaginative man. His heart’s cords were subtle,
swift, and mystical. Songs born of the infinite strangeness of beauty
were ever throbbing at his ear. His senses were as godly as Apollo’s.
The scent of a pinewood smote him from afar. He could watch a
hawk hovering a glimmering speck beneath the clouds. He was quick
and virile, strung to the tense tones of beauty, red and blithe with
the blood of June.
With too precocious a wisdom in the vanities of earth, a semi-
Byronic cynicism had marred his manhood. Like Joan, he had supped
too richly in his April days. Knowledge had bred contempt. To Gabriel
women were so many roses, each with a canker under the petals.
He had been unfortunate in his experimental philosophy. No superb
contradiction had as yet given his shallow pessimism the lie. He had
met women, but not a woman. No Shakespearian divinity had
shamed the cynicism out of his manhood. To him Sarah Golightly of
the Gayety, or Mrs. Marjoy of Saltire, or the numberless worthy
daughters of uninteresting neighbors were equally null and
unlovable. A melancholy being, he had brought himself to the belief
that there were no Britomarts in the woman’s world of the day. He
believed in the possibility of womanly loveliness, adored the ideal
67. Beatrice devoutly, but never prognosticated the flitting of a goddess
athwart his earthly path.
On the identical afternoon that Mrs. Marjoy was waxing
charitable over the moral deficiencies of her acquaintances, Gabriel
and his sister Judith were sessioned in the little red drawing-room at
the hall. John Strong had driven into Rilchester, leaving the pair to
no unwelcome solitude. Saltire Hall seemed to breathe anew through
its quaint casements and antique galleries when its most Victorian
master had vanished for a season.
Now Judith Strong was the one woman in the world who
reclaimed her brother from the charge of callow pessimism. She was
one of those grave, lovable, stately beings who shed over the world
a lustre of truth. With hair of red gold, eyes dark and contemplative,
a complexion delicately pale, she bore upon her face the benign and
tender divineness of a young Madonna. Her soul was clear and calm
as a crystal sky. A sympathetic wisdom had dowered her with a
charm that graced her womanhood like a crown of pearls. To Gabriel
she was sister, friend, and mother. The two loved each other with an
inseparable tenderness that was, indeed, Christian. Judith had
learned to comprehend the subtler instincts of her brother’s nature.
He was no ordinary man, in her opinion, and she was jealous for his
happiness as for her own faith. But for Judith Saltire would have
been a dry desert to the man’s soul.
They had been singing together that afternoon certain old ballads
and glees that would have kindled the Pepysian ardor. Judith’s long,
lithe fingers were magical on the keys. Her whole being begot music.
Gabriel had listened to her playing that afternoon with infinite
sympathy of soul. She seemed as spiritual to him, as he sat in the
window-seat and watched her, as some fair woman stolen from
Rossetti’s brain.
They partook of tea together by the open window, where roses
nodded against a gossamer veil of gold. Gardens stretched below
into the wastes of the woods, a dim maze of yews and lilacs, laurels
and stately firs. It was like some Tuscan landscape spread in quaint
loveliness upon one of Angelico’s frescoes. Mystery brooded on the
68. air. The warm hush of the summer noon was unbroken save by the
distant sound of reaping in the meadows.
Judith and her brother were in a solemn humor. Music had
inspired them to still thought and tenderness of mood. Brother and
sister, woman and man, they were glad of each other’s sympathy,
grateful for solitude and unbroken union of soul. Judith had long
been troubled in her heart for her brother’s future. She knew too
well the sensitive necessity that watched over such a mind as his. All
women are fearful of prophesying pain for those they love. And
Judith feared in measure for her brother.
“Gabriel,” she said, anon, with her stately and simple directness
of expression, “it is strange to me that you do not tire of this place
and the sameness of its ways. Small decorums and small circles
seem so foreign to your nature. It is a year since you were in Italy.
You must chafe at times in Saltire. I should have thought liberty
essential to a man of your temper.”
Her brother smiled at her with an amused melancholy that often
found expression on his face.
“You mean that I am too much here?” he said.
“Not for us, dear. But you are a man of talent, and—”
She hesitated a moment, gazing with an intensity of thought into
the blue distance.
“Well?”
“My words were running over fast.”
“My dear girl, say anything you like to me; you are too honest for
me to be offended.”
Judith drew her chair nearer to his, and, leaning her elbows on
its arms, looked into her brother’s face.
“It is not good for a man to live always at home,” she said.
“Is it my fault?”
“No. I know father desires to keep you here. He is proud of you,
and ambitious—God pardon me—in a mistaken way. But then, my
dear Gabriel, a father must recognize the individual personality of his
son. He can only wrong him till he treats him as a fellow-man and
not as a child. Both of you may suffer through your amiable apathy.”
“Go on.”