Book Image

C# 7 and .NET Core 2.0 Blueprints

By : Dirk Strauss, Jas Rademeyer
Book Image

C# 7 and .NET Core 2.0 Blueprints

By: Dirk Strauss, Jas Rademeyer

Overview of this book

.NET Core is a general purpose, modular, cross-platform, and open source implementation of .NET. With the latest release of .NET Core, many more APIs are expected to show up, which will make APIs consistent across .Net Framework, .NET Core, and Xamarin. This step-by-step guide will teach you the essential .NET Core and C# concepts with the help of real-world projects. The book starts with a brief introduction to the latest features of C# 7 and .NET Core 2.0 before moving on to explain how C# 7 can be implemented using the object-oriented paradigm. You'll learn to work with relational data using Entity Framework and see how to use ASP.NET Core practically. This book will show you how .NET Core allows the creations of cross-platform applications. You'll also learn about SignalR to add real-time functionality to your application. Then you will see how to use MongoDB and how to implement MongoDB into your applications. You'll learn about serverless computing and OAuth concepts, along with running ASP.NET Core applications with Docker Compose. This project-based guide uses practical applications to demonstrate these concepts. By the end of the book, you'll be proficient in developing applications using .NET Core 2.0.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
Dedication
Packt Upsell
Contributors
Preface
Index

Preface

Welcome to C# 7 and .NET Core 2.0 Blueprints. The power of .NET Core 2.0 is illustrated by taking a blueprint approach to common everyday applications. You will learn how to work with .NET Core 2.0 while creating exciting applications that you can use.

Who this book is for

This book is aimed at developers who have a good grasp of C# as a programming language but might need to learn more about .NET Core in general.

What this book covers

Chapter 1, eBook Manager and Catalogue App, covers the new features introduced in C# 7, which allow developers to write less code and be more productive. We will create an eBook manager application. If you are like me, you have eBooks scattered all over your hard drive and some external drives as well. This application will provide a mechanism to bring all these various locations together into a virtual storage space. The application is functional, but it can be further enhanced to suit your needs.

Chapter 2, Cricket Score Calculator and Tracker, says that object-oriented programming (OOP) is a crucial element of writing .NET applications. Proper OOP ensures that developers can easily share code between projects. You don't have to rewrite code that has already been written. In this chapter, we will create an ASP.NET Bootstrap web application that keeps track of the cricket score of your two favorite teams. It is also with this application that the principles of object-oriented programming will become evident.

Chapter 3, Cross Platform .NET Core System Info Manager, is all about what .NET Core is; .NET Core allows us to create applications that will run on Windows, macOS, and Linux. To illustrate this in this chapter, we will be creating a simple Information Dashboard application that displays information about the computer we are running on as well as the weather conditions at the location of that machine.

Chapter 4, Task Bug Logging ASP .NET Core MVC App, takes a look at using MongoDB with ASP.NET Core MVC by creating a task/bug logging application. MongoDB allows developers to be more productive and can easily be added to .NET Core.

Chapter 5, ASP.NET SignalR Chat Application, begins by getting you to imagine having the ability to have your server-side code push data to your web page in real time, without the user needing to refresh the page. The ASP.NET SignalR library provides developers with a simplified method to add real-time web functionality to applications. FYI, keep this chapter in mind when going through Chapter 8, Twitter Clone Using OAuth. This is a perfect application to integrate SignalR into.

Chapter 6, Web Research Tool with Entity Framework Core, discusses Entity Framework Core, which is an essential piece in our .NET Core education. One of the most frustrating parts of developing an application that needs to read data from and write data to some sort of database is trying to get the communication layer between your code and the database established. Entity Framework Core solves this easily in .NET Core applications, and this chapter shows you how.

Chapter 7, A Serverless Email Validation Azure Function, shows you how to create an Azure Function and how to call that function from an ASP.NET Core MVC application. The Azure Function will just be validating an email address. Serverless computing is illustrated here, and the benefits will become clear while working through the chapter.

Chapter 8, Twitter Clone Using OAuth, expresses that sometimes I wish I could tweak Twitter a bit to suit my own needs, for example, saving favorite tweets. In this chapter, we will take a look at how easy it is to create a basic Twitter clone using ASP.NET Core MVC. You can then easily add functionality to your application to customize it to your specific requirements.

Chapter 9, Using Docker and ASP.NET Core, explores Docker, which is all the rage these days, and for very good reason. This chapter illustrates how Docker can benefit developers. I will also show you how to create an ASP.NET Core MVC application and run it inside a Docker Container. In the last part of the chapter, we will see how we can use Docker Hub with GitHub to set up automated builds.

To get the most out of this book

The assumption is that you will have a good understanding of C# 6.0 at least. All the examples in this book will make use of C# 7 where relevant.

You will need to have Visual Studio 2017 installed with the latest patch. If you do not have Visual Studio 2017, you can install Visual Studio Community 2017 for free from https://www.visualstudio.com/downloads/.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/CSharp7-and-.NET-Core-2.0-Blueprints. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "You can call the application anything you like, but I called mine eBookManager."

A block of code is set as follows:

namespace eBookManager.Engine 
{ 
    public class DeweyDecimal 
    { 
        public string ComputerScience { get; set; } = "000"; 
        public string DataProcessing { get; set; } = "004"; 
        public string ComputerProgramming { get; set; } = "005"; 
    } 
} 

Any command-line input or output is written as follows:

mongod -dbpath D:MongoTask 

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "After you have added all the storage spaces and eBooks, you will see the Virtual Storage Spaces listed."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.