Professional C# 6 and .NET Core 1.0. Christian Nagel
Читать онлайн книгу.Dependency injection is discussed in Chapter 31, along with other patterns useful with XAML-based applications.
You can decide what device families to support with your applications. Not all device families will be useful for every app.
Will there be newer versions of Windows after Windows 10? Windows 11 is not planned. With Windows apps (which are also known as Metro apps, Windows Store apps, Modern apps, and Universal Windows apps) you’ve targeted either Windows 8 or Windows 8.1. Windows 8 apps typically were also running on Windows 8.1, but not the other way around. Now this is very different. When you create an app for the Universal Windows Platform, you target a version such as 10.0.10130.0 and define what minimum version is available and what latest version was tested, and the assumption is that it runs on future versions as well. Depending on the features you can use for your app and what version you’re expecting the user to have, you can decide what minimum version to support. Personal users will typically automatically update to newer versions; Enterprise users might stick to older versions.
Windows Apps running on the Universal Windows Platform make use of the Windows Runtime and .NET Core. The most important chapters for these app types are Chapter 32, “Windows Apps: User Interfaces,” and Chapter 33, “Advanced Windows Apps.” These apps are also covered in many other chapters, such as Chapter 23 and Chapters 29 through 31.
SOAP Services with WCF
Windows Communication Foundation (WCF) is a feature-rich technology that was meant to replace all communication technologies that were available before WCF by offering SOAP-based communication with all the features used by standards-based web services such as security, transactions, duplex and one-way communication, routing, discovery, and so on. WCF provides you with the ability to build your service one time and then expose this service in many ways (even under different protocols) by making changes within a configuration file. WCF is a powerful but complex way to connect disparate systems. Chapter 44, “Windows Communication Foundation,” covers this in detail.
Web Services with the ASP.NET Web API
An option that is a lot easier for communication and fulfills more than 90 percent of requirements by distributed applications is the ASP.NET Web API. This technology is based on REST (Representational State Transfer), which defines guidelines and best practices for stateless and scalable web services.
The client can receive JSON or XML data. JSON and XML can also be formatted in a way to make use of the Open Data specification (OData).
The features of this new API make it easy to consume from web clients using JavaScript and also by using the Universal Windows Platform.
The ASP.NET Web API is a good approach for creating microservices. The approach to build microservices defines smaller services that can run and be deployed independently, having their own control of a data store.
With ASP.NET 5, the older version of ASP.NET Web API that was separated from ASP.NET MVC now merged with ASP.NET MVC 6 and uses the same types and features.
NOTE The ASP.NET Web API and more information on microservices are covered in Chapter 42.
WebHooks and SignalR
For real-time web functionality and bidirectional communication between the client and the server, WebHooks and SignalR are ASP.NET technology that can be used.
SignalR allows pushing information to connected clients as soon as information is available. SignalR makes use of the WebSocket technology, and it has a fallback to a pull-based mechanism of communication in case WebSockets are not available.
WebHooks allows you to integrate with public services, and these services can call into your public ASP.NET Web API service. WebHooks is a technology to receive push notification from services such as GitHub or Dropbox and many other services.
The foundation of SignalR connection management, grouping of connections, and authorization and integration of WebHooks are discussed in Chapter 43, “WebHooks and SignalR.”
Windows Services
A web service, whether it’s done with WCF or ASP.NET Web Services, needs a host to run. Internet Information Server is usually a good option because of all the services it offers, but it can also be a custom program. With the custom option, creating a background process that runs with the startup of Windows is a Windows Service. This is a program designed to run in the background in Windows NT kernel–based operating systems. Services are useful when you want a program to run continuously and be ready to respond to events without having been explicitly started by the user. A good example is the World Wide Web Service on web servers, which listens for web requests from clients.
It is easy to write services in C#.NET Framework base classes are available in the System.ServiceProcess namespace that handles many of the boilerplate tasks associated with services. In addition, Visual Studio .NET enables you to create a C# Windows Service project, which uses C# source code for a basic Windows Service. Chapter 39, “Windows Services,” explores how to write C# Windows Services.
Web Applications
The original introduction of ASP.NET 1 fundamentally changed the web programming model. ASP.NET 5 is the new major release, which allows the use of .NET Core for high performance and scalability. This new release can also run on Linux systems, which was a high demand.
With ASP.NET 5, ASP.NET Web Forms is no longer covered (this can still be used and is updated with .NET 4.6), so this book has a focus on the modern technology ASP.NET MVC 6, which is part of ASP.NET 5.
ASP.NET MVC is based on the well-known Model View Controller (MVC) pattern for easier unit testing. It also allows a clear separation for writing user interface code with HTML, CSS, and JavaScript, and it only uses C# on the backend.
NOTE Chapter 41, “ASP.NET MVC,” covers ASP.NET MVC 6.
Microsoft Azure
Nowadays you can’t ignore the cloud when considering the development picture. Although there’s not a dedicated chapter on cloud technologies, Microsoft Azure is referenced in several chapters in this book.
Microsoft Azure offers Software as a Service (SaaS), Infrastructure as a Service (IaaS), and Platform as a Service (PaaS), and sometimes offerings are in between these categories. Let’s have a look at some Microsoft Azure offerings.
Software as a Service
SaaS offers complete software; you don’t have to deal with management of servers, updates, and so on. Office 365 is one of the SaaS offerings for using e-mail and other services via a cloud offering. A SaaS offering that’s relevant for developers is Visual Studio Online, which is not Visual Studio running in the browser. Visual Studio Online is the Team Foundation Server in the cloud that can be used as a private code repository, for tracking bugs and work items, and for build and testing services.
Infrastructure as a Service
Another service offering is IaaS. Virtual machines are offered by this service offering. You are responsible for managing the operating system and maintaining updates. When you create virtual machines, you can decide between different hardware offerings starting with shared Cores up to 32 cores (at the time of this writing, but things change quickly). 32 cores, 448 GB RAM, and 6,144 GB local SSD belong to the “G-Series” of machines, which is named after Godzilla.
With preinstalled operating systems you can decide between Windows, Windows Server, Linux, and operating systems that come preinstalled with SQL Server, BizTalk Server, SharePoint, and Oracle.
I use virtual machines often for environments that I need only for several hours a week, as the virtual machines are paid on an hourly basis. In case you want to try compiling and running .NET Core programs on Linux but don’t have a Linux machine, installing such an environment on Microsoft Azure is an easy task.
Platform as a Service
For developers, the most relevant part of Microsoft Azure is PaaS. You can access services for storing and reading data, use computing