Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
46
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 3 The Fundamentals of .NET MAUI

anything that is possible to create in XAML is also possible in C#. You will look through the different possibilities for architecting your applications in the next chapter (Chapter 4).

/Platforms/ Folder

I mentioned that the platform-specific code lives in the Platforms folder. While cross-platform applications provide a nice abstraction from the platforms we wish to support, I still believe it is extremely valuable to know how these platforms behave. Let’s dive in and look at each of the platform folders to understand what is happening.

Android

Inside the Android platform folder you will see the following files:

•\ MainApplication.cs: This is the main entry point for the Android platform. Initially you should note that it does very little. The bit it does is rather important,

though; it is responsible for creating the MauiApp using the MauiProgram class. This is the bridge between the Android application and your cross-platform .NET MAUI code.

•\ MainActivity.cs: An activity in Android development is a type of app component that provides a user interface. The MainActivity starts when your app is loaded. This is typically done by tapping the app icon; however, it can also be triggered by a notification or other source.

•\ AndroidManifest.xml: This file is extremely important. It is how you define the components that make up your application, any permissions it requires, the application

48

Chapter 3 The Fundamentals of .NET MAUI

version information, the minimum and target SDK versions, and any hardware or software features that it requires.

iOS

Inside the iOS platform folder, you will see the following files:

•\ AppDelegate.cs: This class allows you to respond to all platform-specific parts of the application lifecycle.

•\ Info.plist: This file contains configuration about the application. It is like the AndroidManifest.xml file discussed in the Android section. You can change the application’s version and include reasons why your

application requires permission to use certain features.

•\ Program.cs: This is the main entry point.

MacCatalyst

Inside the MacCatalyst platform folder, you will see the following files. It is worth noting that this section is nearly identical to the previous iOS section. It’s been kept separate to provide an easy reference to what the platform folder consists of for MacCatalyst.

•\ AppDelegate.cs: This class allows you to respond to all platform-specific parts of the application lifecycle.

•\ Info.plist: This file contains configuration about the application. It is like the AndroidManifest.xml file discussed in the Android section: you can change the application version and include reasons why your

application requires permission to use certain features.

•\ Program.cs: This is the main entry point.

49

Chapter 3 The Fundamentals of .NET MAUI

Tizen

Inside the Tizen platform folder, you will see the following files:

•\ Main.cs: This is the main entry point for your Tizen application.

•\ tizen-manifest.xml: This file is very similar to the AndroidManifest.xml file. It is how you define the components that make up your application, any permissions it requires, the application version information, the Tizen API version, and any hardware or software features it requires.

Windows

Inside the Windows platform folder, you will see the following files:

•\ app.manifest: The package manifest is an XML document that contains the info the system needs to deploy, display, or update a Windows app. This info includes package identity, package dependencies, required capabilities, visual elements, and extensibility points. Every app package must include one package manifest.

•\ App.xaml and App.xaml.cs: The main entry points for your Windows application

•\ Package.appxmanifest: An application manifest is an XML file that describes and identifies the shared and private side-by-side assemblies that an application should bind to at run time. They should be the

same assembly versions that were used to test the application. Application manifests may also describe metadata for files that are private to the application.

50