Table of Contents

    Introduction	                        1
        Why Second Edition?	                1
        Overview	                        1
        What this Book Includes	            3
        Is this Book for You?	            3
        What Do You Need to Use this Book?	4
        How this Book Is Organized	        4
        What is Left Out	                6
        Use Code Examples	                6
        Customer Support	                6

    1	C# Graphics Basics	                7
        1.1	Coordinate Systems          	7
            1.1.1	Default Coordinates	    7
            1.1.2	Custom Coordinates	    14
        1.2	Create ASP.NET Core Project	    17
        1.3	Examine Project Files	        20
            1.3.1	Pages Folder	        20
            1.3.2	wwwroot Folder	        20
            1.3.3	Other files	            20
        1.4	Create a New Razor Page	        20
            1.4.1	Razor Template	        21
            1.4.2	Model Binding	        22
        1.5	Tag Helpers	                    25
        1.6	Routing	                        26
        1.7	Security	                    26

    2	TypeScript and WebPack	            27
        2.1	Install TypeScript and Node.js	27
        2.2	Compiler Options for TypeScript	29
            2.2.1	Change TypeScript Compiler Parameters	29
            2.2.2	TypeScript Configuration File	30
        2.3	TypeScript Basics	            31
            2.3.1	Static Types	        32
            2.3.2	Interface	            33
            2.3.3	Class	                34
            2.3.4	Enum	                36
            2.3.5	Declaration	            36
            2.3.6	Module	                37
            2.3.7	ES2017 (ES8) Feature Support	39
        2.4	WebPack	                        40
            2.4.1	Install WebPack	        40
            2.4.2	Configure WebPack	    41
            2.4.3	Configuration Options	42
            2.4.4	WebPack Loaders	        44
            2.4.5	WebPack Plugins	        44
            2.4.6	Bundle Other Resources	45
            2.4.7	Library Bundling	    45
            2.4.8	Configuration File	    49
        2.5	Test WebPack	                51
            2.5.1	Web API Service	        51
            2.5.2	Web Service Application	52

    3	RxJS Basics	                        57
        3.1	Reactive Programming	        57
            3.1.1	Proactive vs Reactive	57
            3.1.2	Data Stream and Propagation	58
            3.1.3	Observer API	        59
        3.2	Create Data Streams	            60
            3.2.1	Streams from Existing Data	60
            3.2.2	Generate New Data	    61
        3.3	Operators	                    62
            3.3.1	Map vs flatMap	        62
            3.3.2	Filter Operator	        63
            3.3.3	Reduce vs Scan	        64
        3.4	Time in RxJS	                65
            3.4.1	Interval	            65
            3.4.2	Timer	                66
            3.4.3	Delay	                66
            3.4.4	Buffering	            67
        3.5	Combination Operators	        68
            .5.1	Merge Operator	        69
            3.5.2	Concat Operator	        70
            3.5.3	SwitchAll Operator	    70
            3.5.4	CombineLatest Operator	71
        3.6	Asynchronous Streams	        72

    4	Database and Web Services	        75
        4.1	Data Model	                    75
            4.1.1	Connection String	    75
            4.1.2	Model Data Types	    76
            4.1.3	Data Context	        77
            4.1.4	Initialize Database	    78
            4.1.5	Add Stock Tickers to Database	79
            4.1.6	Add Stock Prices to Database	80
            4.1.7	Check Database	        81
        4.2	ASP.NET Core Web Services	    83
            4.2.1	Create web services	    83
            4.2.2	Get Method	            86
            4.2.3	Post Method	            88
            4.2.4	Put Method	            89
            4.2.5	Delete Method	        89
        4.3	Data Model in Client Side	    89
            4.3.1	Model Interfaces	    90
            4.3.2	Repository with RxJS	90
        4.4	Access Web Service Data	        93
            4.4.1	Display Stock Data      94
            4.4.2	Display Stock Price Data	96
        4.5	CRUD Operations	                98
            4.5.1	Create Operation	    98
            4.5.2	Update Operation	    100
            4.5.3	Delete Operation	    103
            4.5.4	Save Stock Data to Database	104

    5	Angular Basics	                    111
        5.1	Create the Angular Project	    112
            5.1.1	Add a New Angular Project	112
            5.1.2	Update Angular	        113
        5.2	Project Structure	            115
        5.3	Configure Angular Project	    119
        5.4	Bootstrap and Angular Material	120
            5.4.1	Bootstrap	            120
            5.4.2	Bootstrap or Angular Material?	121
            5.4.3	Install Angular Material	122
            5.4.4	Import Material Modules	123
            5.4.5	Install ag-Grid	        124
        5.5	Structure of Angular App	    124
            5.5.1	App Entry Point	        124
            5.5.2	Root Module	            125
            5.5.3	Root Component	        126
            5.5.4	Routing and Navigation	127
            5.5.5	Main HTML Page	        128
        5.6	Data Binding	                129
            5.6.1	Interpolation Binding	129
            5.6.2	One-Way Binding	        133
            5.6.3	Event Binding	        135
            5.6.4	Two-Way Binding	        138
        5.7	Directives	                    141
            5.7.1	Structural Directives	141
            5.7.2	Attribute Directives	144
        5.8	Input and Output Properties	    147
            5.8.1	Multiple Components	    147
            5.8.2	Input Property	        149
            5.8.3	Output Property	        149

    6	Introduction to Angular Elements	153
        6.1	Add Angular Elements Support	153
            6.1.1	Add @angular/elements Package	153
            6.1.2	Add Other Packages	    155
        6.2	Angular Elements Example	    156
            6.2.1	Create Component	    156
            6.2.2	Create Custom Element	158
            6.2.3	Package Angular Elements for Development	159
            6.2.4	Package Angular Elements for Production	161
        6.3	More Custom-Element Examples	163
            6.3.1	Test Angular Material	163
            6.3.2	Test Bootstrap	        167
            6.3.3	Custom Element with Input	171
            6.3.4	Custom Element with Slot	172
            6.3.5	Custom Elements in TypeScript	174
        6.4	Angular Ivy	                    175

    7	Web Services in Angular Elements	177
        7.1	Repository Service in Angular	177
            7.1.1	Get Methods	            178
            7.1.2	Post Methods	        179
            7.1.3	Put Method	            180
            7.1.4	Delete Method	        180
        7.2	Access Web Service Data	        181
            7.2.1	Display Stock Data	    181
            7.2.2	Display Stock Price Data	183
        7.3	Perform CRUD Operations	        186
            7.3.1	Create Operation	    186
            7.3.2	Update Operation	    188
            7.3.3	Delete Operation	    191
            7.3.4	Add Stock Price Data to Database	197

    8	Chart and Graphics	                201
        8.1	Line Charts	                    202
            8.1.1	Install ECharts Package	202
            8.1.2	Simple Line Charts	    204
            8.1.3	Multiple-Line Charts	206
            8.1.4	Line Charts with Two Y Axes	209
        8.2	Specialized 2D Charts	        214
            8.2.1	Area Charts	            214
            8.2.2	Bar Charts	            220
            8.2.3	Pie Charts	            225
            8.2.4	Polar Charts	        229
        8.3	3D Charts and Graphics	        232
            8.3.1	3D Line Charts	        232
            8.3.2	3D Simple Surfaces	    237
            8.3.3	3D Parametric Surfaces	243
        8.4	Stock Charts	                251
            8.4.1	Candlestick Charts	    251
            8.4.2	Candlestick and Volume Charts	256
            8.4.3	Real-Time Stock Charts	260

    9	Real-Time Apps with SignalR	        267
        9.1	Chat App with SignalR	        267
            9.1.1	Add SignalR Client Library	267
            9.1.2	Create a SignalR Hub	268
            9.1.3	Configure SignalR	    268
            9.1.4	Create Chat App	        269
            9.1.5	Test Chat App	        272
        9.2	Whiteboard App with SignalR	    272
            9.2.1	Server-Side Code	    272
            9.2.2	Client-Side Code	    274
            9.2.3	Test Whiteboard App	    276
        9.3	Streaming App with SignalR	    276
            9.3.1	Server-Side Code	    276
            9.3.2	Client-Side Code	    279
            9.3.3	Test Streaming App	    280
        9.4	SignalR and Angular Elements	281
            9.4.1	Server-Side Code	    281
            9.4.2	SignalR Service in Angular	282
            9.4.3	Create Angular Element with SignalR	283
            9.4.4	Test Real-Time Stock Chart	288

    10	Machine Learning	                291
        10.1	Introduction to ML.NET	    291
            10.1.1	Main Features of ML.NET	292
            10.1.2	Code Workflow	        292
            10.1.3	Data Preparation	    293
                10.1.3.1	Filter Data	    294
                10.1.3.2	Replace Missing Data	294
                10.1.3.3	Data Normalization	294
                10.1.3.4	Categorical Data	295
                10.1.3.5	Text Data	    296
            10.1.4	Build Pipelines	        297
            10.1.5	Model Evaluation	    297
        10.2	Sentiment Analysis	        298
            10.2.1	Code-Behind	            298
            10.2.2	Prepare Data	        302
            10.2.3	Build and Train the Model	302
            10.2.4	Model Evaluation	    303
            10.2.5	Razor Page Code	        304
            10.2.6	Confusion Matrix	    306
        10.3	Yin-Yang Classification	    307
            10.3.1	Code-Behind	            307
            10.3.2	Razor Page Code	        311
            10.3.3	Generate Data for Decision Boundary	313
            10.3.4	Visualize Decision Boundary	316
        10.4	Multiclass Classification	320
            10.4.1	Code-Behind	            320
            10.4.2	Prepare Data	        323
            10.4.3	Build and Train the Model	324
            10.4.4	Model Evaluation	    325
            10.4.5	Model Prediction	    325
            10.4.6	Razor Page Code	        326
        10.5	Regression	                330
            10.5.1	Code-Behind	            330
            10.5.2	Prepare Data	        335
            10.5.3	Build and Train the Model	336
            10.5.4	Model Evaluation	    337
            10.5.5	Model Prediction	    338
            10.5.6	Visualize Predicted Results	338
            10.5.7	Razor Page Code	        340
        10.6	Clustering	                344
            10.6.1	Code-behind	            344
            10.6.2	Prepare Data	        347
            10.6.3	Build and Train the Model	348
            10.6.4	Model Evaluation and Prediction	348
            10.6.5	Visualize Predicted Results	349
            10.6.6	Razor Page Code	        350

    11	Mini SPAs	                        355
        11.1	Navigo Router	            355
            11.1.1	Installation	        355
            11.1.2	How to Use Navigo	    356
        11.2	Create Mini SPA	            357
            11.2.1	Razor Page	            357
            11.2.2	TypeScript Code	        357
            11.2.3	Test Mini SPA	        358
        11.3	Mini SPA with Angular Elements	360
            11.3.1	Mini SPA Pages	        360
            11.3.2	Razor Page	            361
            11.3.3	TypeScript Code	        361
            11.3.4	Test Mini SPA	        362

    12	Authentication and Authorization	365
        12.1	Identity in ASP.NET Core	365
            12.1.1	Installation	        365
            12.1.2	Identity User Entity	366
            12.1.3	Identity Database	    367
            12.1.4	Scaffold Identity	    370
            12.1.5	Code Adjustments	    373
            12.1.6	Layout Changes	        374
        12.2	Test Default Identity	    375
            12.2.1	User Registration	    376
            12.2.2	User Login	            378
            12.2.3	Two-Factor Authentication	379
        12.3	Authorization	            383
            12.3.1	Authorize a Page	    383
            12.3.2	Authorize a Folder	    384
            12.3.3	Anonymous Access	    384
            12.3.4	Test Authorization	    385
        12.4	Customize Identity	        386
            12.4.1	Replace Default Identity	386
            12.4.2	Customize Login Page	387

    13	Advanced Topics in Razor Pages	    391
        13.1	Dependency Injection	    391
            13.1.1	Simple DI Example	    391
            13.1.2	Service Lifetime	    394
            13.1.3	DI Lifetime Example	    395
        13.2	Custom Tag Helpers	        398
            13.2.1	How Tag Helpers Work	398
            13.2.2	HTML Helpers vs Tag Helpers	399
            13.2.3	Create Custom Tag Helpers	400
            13.2.4	Pager Tag Helper	    402
        13.3	Razor Class Libraries	    406
            13.3.1	Create a Razor Class Library	406
            13.3.2	Use Razor Class Library	408
            13.3.3	Override Razor Class Library	411
    
    Index	                                413