8 Enterprise app development

 

This chapter covers

  • Moving logic out of the UI and into services
  • Authentication
  • Using the generic host builder pattern to register services and resources
  • Dependency injection
  • Full stack architecture patterns for .NET MAUI apps

There’s a good chance you’ve chosen to build an app in .NET MAUI because it fits in with your existing .NET stack. Writing apps in .NET MAUI offers several benefits, but perhaps chief among these is the opportunity to use your existing skills in .NET and easily integrate a .NET MAUI app into an existing solution or code base.

Many of the patterns and practices you’re familiar with from other .NET project types can be used in .NET MAUI apps. In this chapter, we’ll look at some of these, including abstracting logic into interfaces and implementing that logic in services. We’ll also look at some other enterprise patterns in .NET MAUI development, such as dependency injection (DI) and authentication and how we can simplify local development of full-stack, cloud-based solutions with .NET MAUI client apps.

If you already have your cloud or web infrastructure running on .NET and you want to add a mobile or desktop app, .NET MAUI is a no-brainer. In this chapter, we’ll look at how MauiStockTake.UI slots into our existing .NET API solution and how we can share code between the different layers of the solution.

8.1 Moving logic to services

8.1.1 Defining requirements

8.1.2 Implementing the authentication service

8.2 Using the generic host builder and dependency injection

8.2.1 Registering resources, services, and other dependencies

8.2.2 Consuming services

8.3 Consuming web services

8.3.1 Adding the client project

8.3.2 Using a delegating handler

8.3.3 Using IHttpClientFactory

8.3.4 Adding the remaining MauiStockTake services

8.4 Full-stack app architecture

8.4.1 Project Organization