From 63c23198a50230f3f6f3e3b2e2612c517fa2510e Mon Sep 17 00:00:00 2001 From: Alvin Ashcraft Date: Sat, 16 Sep 2023 16:30:52 -0400 Subject: [PATCH] Adding code for completed chapter 13 solution --- .../Complete/UnoMediaCollection/.gitignore | 403 ++++++++++++++++++ .../UnoMediaCollection/.vscode/launch.json | 53 +++ .../UnoMediaCollection/.vscode/settings.json | 7 + .../UnoMediaCollection/.vscode/tasks.json | 53 +++ .../Complete/UnoMediaCollection/.vsconfig | 38 ++ .../UnoMediaCollection/Directory.Build.props | 67 +++ .../Directory.Build.targets | 6 + .../Directory.Packages.props | 36 ++ .../UnoMediaCollection.Base/AppHead.xaml | 17 + .../UnoMediaCollection.Base/AppHead.xaml.cs | 29 ++ .../Icons/appconfig.svg | 137 ++++++ .../UnoMediaCollection.Base/Icons/iconapp.svg | 42 ++ .../Splash/splash_screen.svg | 137 ++++++ .../UnoMediaCollection.Base.csproj | 12 + .../UnoMediaCollection.Base/base.props | 30 ++ .../Serialization/WeatherForecastContext.cs | 25 ++ .../UnoMediaCollection.DataContracts.csproj | 6 + .../WeatherForecast.cs | 16 + .../Android/AndroidManifest.xml | 4 + .../Android/Assets/AboutAssets.txt | 22 + .../Android/Main.Android.cs | 43 ++ .../Android/MainActivity.Android.cs | 17 + .../Android/Resources/AboutResources.txt | 47 ++ .../Android/Resources/values/Strings.xml | 5 + .../Android/Resources/values/Styles.xml | 22 + .../Android/environment.conf | 2 + .../UnoMediaCollection.Mobile.csproj | 58 +++ .../Apis/WeatherForecastApi.cs | 48 +++ .../UnoMediaCollection.Server/GlobalUsings.cs | 3 + .../UnoMediaCollection.Server/Program.cs | 58 +++ .../Properties/launchSettings.json | 33 ++ .../UnoMediaCollection.Server.csproj | 18 + .../appsettings.Development.json | 8 + .../appsettings.json | 9 + .../UnoMediaCollection.Wasm/LinkerConfig.xml | 11 + .../UnoMediaCollection.Wasm/Program.cs | 14 + .../Properties/launchSettings.json | 30 ++ .../UnoMediaCollection.Wasm.csproj | 82 ++++ .../UnoMediaCollection.Wasm/WasmCSS/Fonts.css | 28 ++ .../WasmScripts/AppManifest.js | 3 + .../manifest.webmanifest | 10 + .../wwwroot/staticwebapp.config.json | 30 ++ .../wwwroot/web.config | 78 ++++ .../Package.appxmanifest | 43 ++ .../PublishProfiles/win10-arm64.pubxml | 20 + .../PublishProfiles/win10-x64.pubxml | 20 + .../PublishProfiles/win10-x86.pubxml | 20 + .../Properties/launchsettings.json | 10 + .../Resources.lang-en-us.resw | 123 ++++++ .../UnoMediaCollection.Windows.csproj | 84 ++++ .../UnoMediaCollection.Windows/app.manifest | 25 ++ .../UnoMediaCollection/UnoMediaCollection.sln | 193 +++++++++ .../UnoMediaCollection/App.cs | 108 +++++ .../UnoMediaCollection/AppResources.xaml | 13 + .../UnoMediaCollection/Assets/Icons/back.svg | 3 + .../UnoMediaCollection/Assets/SharedAssets.md | 34 ++ .../Business/Models/AppConfig.cs | 7 + .../UnoMediaCollection/Enums/ItemType.cs | 9 + .../UnoMediaCollection/Enums/LocationType.cs | 8 + .../UnoMediaCollection/GlobalUsings.cs | 22 + .../Infrastructure/DebugHandler.cs | 42 ++ .../Interfaces/IDataService.cs | 18 + .../Interfaces/INavigationService.cs | 12 + .../UnoMediaCollection/ItemDetailsPage.xaml | 84 ++++ .../ItemDetailsPage.xaml.cs | 44 ++ .../UnoMediaCollection/MainPage.xaml | 78 ++++ .../UnoMediaCollection/MainPage.xaml.cs | 25 ++ .../UnoMediaCollection/Model/MediaItem.cs | 13 + .../UnoMediaCollection/Model/Medium.cs | 11 + .../Services/Caching/IWeatherCache.cs | 7 + .../Services/Caching/WeatherCache.cs | 76 ++++ .../Services/DataService.cs | 160 +++++++ .../Services/Endpoints/IApiClient.cs | 11 + .../Services/NavigationService.cs | 80 ++++ .../Strings/en/Resources.resw | 123 ++++++ .../UnoMediaCollection.csproj | 81 ++++ .../ViewModels/ItemDetailsViewModel.cs | 157 +++++++ .../ViewModels/MainViewModel.cs | 98 +++++ .../appsettings.development.json | 9 + .../UnoMediaCollection/appsettings.json | 8 + .../solution-config.props.sample | 22 + 81 files changed, 3698 insertions(+) create mode 100644 Chapter13/Complete/UnoMediaCollection/.gitignore create mode 100644 Chapter13/Complete/UnoMediaCollection/.vscode/launch.json create mode 100644 Chapter13/Complete/UnoMediaCollection/.vscode/settings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/.vscode/tasks.json create mode 100644 Chapter13/Complete/UnoMediaCollection/.vsconfig create mode 100644 Chapter13/Complete/UnoMediaCollection/Directory.Build.props create mode 100644 Chapter13/Complete/UnoMediaCollection/Directory.Build.targets create mode 100644 Chapter13/Complete/UnoMediaCollection/Directory.Packages.props create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/appconfig.svg create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/iconapp.svg create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Splash/splash_screen.svg create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/UnoMediaCollection.Base.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/base.props create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/Serialization/WeatherForecastContext.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/UnoMediaCollection.DataContracts.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/WeatherForecast.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/AndroidManifest.xml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Assets/AboutAssets.txt create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Main.Android.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/MainActivity.Android.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/AboutResources.txt create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Strings.xml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Styles.xml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/environment.conf create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/UnoMediaCollection.Mobile.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Apis/WeatherForecastApi.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/GlobalUsings.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Program.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Properties/launchSettings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/UnoMediaCollection.Server.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.Development.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/LinkerConfig.xml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Program.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Properties/launchSettings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmCSS/Fonts.css create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmScripts/AppManifest.js create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/manifest.webmanifest create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/staticwebapp.config.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/web.config create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Package.appxmanifest create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-arm64.pubxml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x64.pubxml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x86.pubxml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/launchsettings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Resources.lang-en-us.resw create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/UnoMediaCollection.Windows.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/app.manifest create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.sln create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/App.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/AppResources.xaml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/Icons/back.svg create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/SharedAssets.md create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Business/Models/AppConfig.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/ItemType.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/LocationType.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/GlobalUsings.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Infrastructure/DebugHandler.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/IDataService.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/INavigationService.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ItemDetailsPage.xaml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ItemDetailsPage.xaml.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/MainPage.xaml create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/MainPage.xaml.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Model/MediaItem.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Model/Medium.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Services/Caching/IWeatherCache.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Services/Caching/WeatherCache.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Services/DataService.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Services/Endpoints/IApiClient.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Services/NavigationService.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Strings/en/Resources.resw create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/UnoMediaCollection.csproj create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ViewModels/ItemDetailsViewModel.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ViewModels/MainViewModel.cs create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/appsettings.development.json create mode 100644 Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/appsettings.json create mode 100644 Chapter13/Complete/UnoMediaCollection/solution-config.props.sample diff --git a/Chapter13/Complete/UnoMediaCollection/.gitignore b/Chapter13/Complete/UnoMediaCollection/.gitignore new file mode 100644 index 0000000..bc55501 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/.gitignore @@ -0,0 +1,403 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml + +# Single Target Config +solution-config.props +# Windows Publish Profiles +!**/*.Windows/Properties/PublishProfiles/*.pubxml \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/.vscode/launch.json b/Chapter13/Complete/UnoMediaCollection/.vscode/launch.json new file mode 100644 index 0000000..4778bda --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/.vscode/launch.json @@ -0,0 +1,53 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": "Debug (Chrome, WebAssembly)", + "type": "chrome", + "request": "launch", + "url": "http://localhost:5000", + "webRoot": "${workspaceFolder}/UnoMediaCollection.Wasm", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "timeout": 30000, + "server": { + "runtimeExecutable": "dotnet", + "program": "run", + "outputCapture": "std", + "timeout": 30000, + "cwd": "${workspaceFolder}/UnoMediaCollection.Wasm" + } + }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": "Skia.GTK (Debug)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-skia-gtk", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/UnoMediaCollection.Skia.Gtk/bin/Debug/net7.0/UnoMediaCollection.Skia.Gtk.dll", + "args": [], + "env": { + "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" + }, + "cwd": "${workspaceFolder}/UnoMediaCollection.Skia.Gtk", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": "Uno Platform Mobile", + "type": "Uno", + "request": "launch", + // any Uno* task will do, this is simply to satisfy vscode requirement when a launch.json is present + "preLaunchTask": "Uno: android | Debug | android-x64" + }, + ] +} diff --git a/Chapter13/Complete/UnoMediaCollection/.vscode/settings.json b/Chapter13/Complete/UnoMediaCollection/.vscode/settings.json new file mode 100644 index 0000000..23133fc --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.expand": false, + "explorer.fileNesting.patterns": { + "*.xaml": "$(capture).xaml.cs" + } +} diff --git a/Chapter13/Complete/UnoMediaCollection/.vscode/tasks.json b/Chapter13/Complete/UnoMediaCollection/.vscode/tasks.json new file mode 100644 index 0000000..0d87232 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/.vscode/tasks.json @@ -0,0 +1,53 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build-wasm", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish-wasm", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build-skia-gtk", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/UnoMediaCollection.Skia.Gtk/UnoMediaCollection.Skia.Gtk.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish-skia-gtk", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/UnoMediaCollection.Skia.Gtk/UnoMediaCollection.Skia.Gtk.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/Chapter13/Complete/UnoMediaCollection/.vsconfig b/Chapter13/Complete/UnoMediaCollection/.vsconfig new file mode 100644 index 0000000..1c9c228 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/.vsconfig @@ -0,0 +1,38 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.VisualStudio.Component.CoreEditor", + "Microsoft.VisualStudio.Workload.CoreEditor", + "Microsoft.NetCore.Component.SDK", + "Microsoft.NetCore.Component.DevelopmentTools", + "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions", + "Microsoft.NetCore.Component.Web", + "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites", + "Microsoft.VisualStudio.Component.TextTemplating", + "Microsoft.VisualStudio.Component.IISExpress", + "Component.Microsoft.Web.LibraryManager", + "Microsoft.VisualStudio.ComponentGroup.Web", + "Microsoft.VisualStudio.Component.Web", + "Microsoft.VisualStudio.ComponentGroup.Web.Client", + "Microsoft.VisualStudio.Workload.NetWeb", + "Microsoft.VisualStudio.ComponentGroup.Azure.Prerequisites", + "Microsoft.VisualStudio.Workload.Azure", + "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", + "Microsoft.VisualStudio.Component.Debugger.JustInTime", + "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", + "Microsoft.VisualStudio.Workload.ManagedDesktop", + "Microsoft.Component.NetFX.Native", + "Microsoft.VisualStudio.Component.Graphics", + "Component.OpenJDK", + "Microsoft.VisualStudio.Component.MonoDebugger", + "Microsoft.VisualStudio.Component.Merq", + "Component.Xamarin.RemotedSimulator", + "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine", + "Component.Xamarin", + "Component.Android.SDK32", + "Microsoft.VisualStudio.Workload.NetCrossPlat", + "Microsoft.VisualStudio.Workload.NetCoreTools", + "Microsoft.VisualStudio.ComponentGroup.Maui.All" + ] +} diff --git a/Chapter13/Complete/UnoMediaCollection/Directory.Build.props b/Chapter13/Complete/UnoMediaCollection/Directory.Build.props new file mode 100644 index 0000000..a319151 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/Directory.Build.props @@ -0,0 +1,67 @@ + + + + + + + + enable + enable + + portable + True + + true + + $(NoWarn);CA1416;NU1507 + + en + + false + false + false + false + false + + + + + + true + 21.0 + + + + + true + 14.2 + + + + + true + 10.14 + + + + + true + 14.0 + + + + + true + 10.0.18362.0 + 10.0.18362.0 + win10-x86;win10-x64;win10-arm64 + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/Directory.Build.targets b/Chapter13/Complete/UnoMediaCollection/Directory.Build.targets new file mode 100644 index 0000000..30332cf --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/Directory.Build.targets @@ -0,0 +1,6 @@ + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/Directory.Packages.props b/Chapter13/Complete/UnoMediaCollection/Directory.Packages.props new file mode 100644 index 0000000..0923c5f --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/Directory.Packages.props @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml new file mode 100644 index 0000000..f5b611e --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml.cs new file mode 100644 index 0000000..01fe0d2 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/AppHead.xaml.cs @@ -0,0 +1,29 @@ +using Microsoft.UI.Xaml; +using Uno.Resizetizer; + +namespace UnoMediaCollection +{ + public sealed partial class AppHead : App + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public AppHead() + { + this.InitializeComponent(); + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + base.OnLaunched(args); + + MainWindow.SetWindowIcon(); + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/appconfig.svg b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/appconfig.svg new file mode 100644 index 0000000..3106b1a --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/appconfig.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/iconapp.svg b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/iconapp.svg new file mode 100644 index 0000000..f621ea5 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Icons/iconapp.svg @@ -0,0 +1,42 @@ + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Splash/splash_screen.svg b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Splash/splash_screen.svg new file mode 100644 index 0000000..3106b1a --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/Splash/splash_screen.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/UnoMediaCollection.Base.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/UnoMediaCollection.Base.csproj new file mode 100644 index 0000000..44cf86c --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/UnoMediaCollection.Base.csproj @@ -0,0 +1,12 @@ + + + + net7.0 + false + + + + + + + \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/base.props b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/base.props new file mode 100644 index 0000000..9b39b5c --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Base/base.props @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/Serialization/WeatherForecastContext.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/Serialization/WeatherForecastContext.cs new file mode 100644 index 0000000..9f67433 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/Serialization/WeatherForecastContext.cs @@ -0,0 +1,25 @@ +using System.Collections.Immutable; +using System.Text.Json.Serialization; + +namespace UnoMediaCollection.DataContracts.Serialization +{ + /// + /// Generated class for System.Text.Json Serialization + /// + /// + /// When using the JsonSerializerContext you must add the JsonSerializableAttribute + /// for each type that you may need to serialize / deserialize including both the + /// concrete type and any interface that the concrete type implements. + /// For more information on the JsonSerializerContext see: + /// https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?WT.mc_id=DT-MVP-5002924 + /// + [JsonSerializable(typeof(WeatherForecast))] + [JsonSerializable(typeof(WeatherForecast[]))] + [JsonSerializable(typeof(IEnumerable))] + [JsonSerializable(typeof(IImmutableList))] + [JsonSerializable(typeof(ImmutableList))] + [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] + public partial class WeatherForecastContext : JsonSerializerContext + { + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/UnoMediaCollection.DataContracts.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/UnoMediaCollection.DataContracts.csproj new file mode 100644 index 0000000..47df750 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/UnoMediaCollection.DataContracts.csproj @@ -0,0 +1,6 @@ + + + net7.0 + true + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/WeatherForecast.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/WeatherForecast.cs new file mode 100644 index 0000000..72a34dc --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.DataContracts/WeatherForecast.cs @@ -0,0 +1,16 @@ +namespace UnoMediaCollection.DataContracts +{ + /// + /// A Weather Forecast for a specific date + /// + /// Gets the Date of the Forecast. + /// Gets the Forecast Temperature in Celsius. + /// Get a description of how the weather will feel. + public record WeatherForecast(DateOnly Date, double TemperatureC, string? Summary) + { + /// + /// Gets the Forecast Temperature in Fahrenheit + /// + public double TemperatureF => 32 + (TemperatureC * 9 / 5); + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/AndroidManifest.xml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/AndroidManifest.xml new file mode 100644 index 0000000..95ae075 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Assets/AboutAssets.txt b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Assets/AboutAssets.txt new file mode 100644 index 0000000..210a93b --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Assets/AboutAssets.txt @@ -0,0 +1,22 @@ +To add cross-platform image assets for your Uno Platform app, use the Assets folder +in the shared project instead. Assets in this folder are Android-only assets. + +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories) and given a Build Action of "AndroidAsset". + +These files will be deployed with you package and will be accessible using Android's +AssetManager, like this: + +public class ReadAsset : Activity +{ + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + InputStream input = Assets.Open ("my_asset.txt"); + } +} + +Additionally, some Android functions will automatically load asset files: + +Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Main.Android.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Main.Android.cs new file mode 100644 index 0000000..b8a9cc4 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Main.Android.cs @@ -0,0 +1,43 @@ +using Android.App; +using Android.Content; +using Android.OS; +using Android.Runtime; +using Android.Views; +using Android.Widget; +using Com.Nostra13.Universalimageloader.Core; +using Microsoft.UI.Xaml.Media; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace UnoMediaCollection.Droid +{ + [global::Android.App.ApplicationAttribute( + Label = "@string/ApplicationName", + Icon = "@mipmap/iconapp", + LargeHeap = true, + HardwareAccelerated = true, + Theme = "@style/AppTheme" + )] + public class Application : Microsoft.UI.Xaml.NativeApplication + { + public Application(IntPtr javaReference, JniHandleOwnership transfer) + : base(() => new AppHead(), javaReference, transfer) + { + ConfigureUniversalImageLoader(); + } + + private static void ConfigureUniversalImageLoader() + { + // Create global configuration and initialize ImageLoader with this config + ImageLoaderConfiguration config = new ImageLoaderConfiguration + .Builder(Context) + .Build(); + + ImageLoader.Instance.Init(config); + + ImageSource.DefaultImageLoader = ImageLoader.Instance.LoadImageAsync; + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/MainActivity.Android.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/MainActivity.Android.cs new file mode 100644 index 0000000..770b872 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/MainActivity.Android.cs @@ -0,0 +1,17 @@ +using Android.App; +using Android.Content.PM; +using Android.OS; +using Android.Views; +using Android.Widget; + +namespace UnoMediaCollection.Droid +{ + [Activity( + MainLauncher = true, + ConfigurationChanges = global::Uno.UI.ActivityHelper.AllConfigChanges, + WindowSoftInputMode = SoftInput.AdjustNothing | SoftInput.StateHidden + )] + public class MainActivity : Microsoft.UI.Xaml.ApplicationActivity + { + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/AboutResources.txt b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/AboutResources.txt new file mode 100644 index 0000000..17e3b13 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/AboutResources.txt @@ -0,0 +1,47 @@ +To add cross-platform image assets for your Uno Platform app, use the Assets folder +in the shared project instead. Resources in this folder are Android-only. + +Images, layout descriptions, binary blobs and string dictionaries can be included +in your application as resource files. Various Android APIs are designed to +operate on the resource IDs instead of dealing with images, strings or binary blobs +directly. + +For example, a sample Android app that contains a user interface layout (main.axml), +an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) +would keep its resources in the "Resources" directory of the application: + +Resources/ + drawable/ + icon.png + + layout/ + main.axml + + values/ + strings.xml + +In order to get the build system to recognize Android resources, set the build action to +"AndroidResource". The native Android APIs do not operate directly with filenames, but +instead operate on resource IDs. When you compile an Android application that uses resources, +the build system will package the resources for distribution and generate a class called "R" +(this is an Android convention) that contains the tokens for each one of the resources +included. For example, for the above Resources layout, this is what the R class would expose: + +public class R { + public class drawable { + public const int icon = 0x123; + } + + public class layout { + public const int main = 0x456; + } + + public class strings { + public const int first_string = 0xabc; + public const int second_string = 0xbcd; + } +} + +You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main +to reference the layout/main.axml file, or R.strings.first_string to reference the first +string in the dictionary file values/strings.xml. diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Strings.xml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Strings.xml new file mode 100644 index 0000000..03391a8 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Strings.xml @@ -0,0 +1,5 @@ + + + Hello World, Click Me! + UnoMediaCollection + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Styles.xml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Styles.xml new file mode 100644 index 0000000..c02bd06 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/Resources/values/Styles.xml @@ -0,0 +1,22 @@ + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/environment.conf b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/environment.conf new file mode 100644 index 0000000..fa6c2e3 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/Android/environment.conf @@ -0,0 +1,2 @@ +# See this for more details: http://developer.xamarin.com/guides/android/advanced_topics/garbage_collection/ +MONO_GC_PARAMS=bridge-implementation=tarjan,nursery-size=32m,soft-heap-limit=256m \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/UnoMediaCollection.Mobile.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/UnoMediaCollection.Mobile.csproj new file mode 100644 index 0000000..551a45b --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Mobile/UnoMediaCollection.Mobile.csproj @@ -0,0 +1,58 @@ + + + net7.0-android + $(OverrideTargetFrameworks) + true + Exe + + UnoMediaCollection + + com.learnwinui3.UnoMediaCollection + E081709F-8906-47DA-8BB2-B3959AA93CB7 + + 1.0 + 1 + + Android\AndroidManifest.xml + + + + + True + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Apis/WeatherForecastApi.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Apis/WeatherForecastApi.cs new file mode 100644 index 0000000..2969f02 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Apis/WeatherForecastApi.cs @@ -0,0 +1,48 @@ +namespace UnoMediaCollection.Server.Apis +{ + internal static class WeatherForecastApi + { + private const string Tag = "Weather"; + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + internal static WebApplication MapWeatherApi(this WebApplication app) + { + app.MapGet("/api/weatherforecast", GetForecast) + .WithTags(Tag) + .WithName(nameof(GetForecast)); + return app; + } + + /// + /// Creates a make believe weather forecast for the next 5 days. + /// + /// + /// A fake 5 day forecast + /// A 5 Day Forecast + /// Weather Forecast returned + [Produces("application/json")] + [ProducesResponseType(typeof(IEnumerable), 200)] + private static IEnumerable GetForecast(ILoggerFactory loggerFactory) + { + var logger = loggerFactory.CreateLogger(nameof(WeatherForecastApi)); + logger.LogDebug("Getting Weather Forecast."); + + return Enumerable.Range(1, 5).Select(index => + new WeatherForecast( + DateOnly.FromDateTime(DateTime.Now.AddDays(index)), + Random.Shared.Next(-20, 55), + Summaries[Random.Shared.Next(Summaries.Length)] + ) + ) + .Select(x => + { + logger.LogInformation("Weather forecast for {Date} is a {Summary} {TemperatureC}°C", x.Date, x.Summary, x.TemperatureC); + return x; + }) + .ToArray(); + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/GlobalUsings.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/GlobalUsings.cs new file mode 100644 index 0000000..72815b0 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/GlobalUsings.cs @@ -0,0 +1,3 @@ +global using Microsoft.AspNetCore.Mvc; +global using UnoMediaCollection.DataContracts; +global using UnoMediaCollection.Server.Apis; diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Program.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Program.cs new file mode 100644 index 0000000..1b1e58d --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Program.cs @@ -0,0 +1,58 @@ +using Uno.Wasm.Bootstrap.Server; +using UnoMediaCollection.DataContracts.Serialization; + +try +{ + var builder = WebApplication.CreateBuilder(args); + + // Configure the JsonOptions to use the generated WeatherForecastContext + builder.Services.Configure(options => + options.JsonSerializerOptions.AddContext()); + // Configure the RouteOptions to use lowercase URLs + builder.Services.Configure(options => + options.LowercaseUrls = true); + + // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle + builder.Services.AddEndpointsApiExplorer(); + builder.Services.AddSwaggerGen(c => + { + // Include XML comments for all included assemblies + Directory.EnumerateFiles(AppContext.BaseDirectory, "*.xml") + .Where(x => x.Contains("UnoMediaCollection") + && File.Exists(Path.Combine( + AppContext.BaseDirectory, + $"{Path.GetFileNameWithoutExtension(x)}.dll"))) + .ToList() + .ForEach(path => c.IncludeXmlComments(path)); + }); + + var app = builder.Build(); + + // Configure the HTTP request pipeline. + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + app.UseSwaggerUI(); + } + + app.UseHttpsRedirection(); + + app.UseUnoFrameworkFiles(); + app.MapFallbackToFile("index.html"); + + app.MapWeatherApi(); + app.UseStaticFiles(); + + await app.RunAsync(); +} +catch (Exception ex) +{ + Console.Error.WriteLine("Application terminated unexpectedly"); + Console.Error.WriteLine(ex); +#if DEBUG + if (System.Diagnostics.Debugger.IsAttached) + { + System.Diagnostics.Debugger.Break(); + } +#endif +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Properties/launchSettings.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Properties/launchSettings.json new file mode 100644 index 0000000..80bc4a7 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/Properties/launchSettings.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:5000", + "sslPort": 5001 + } + }, + "profiles": { + "UnoMediaCollection.Server": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:5000;http://localhost:5001", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/UnoMediaCollection.Server.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/UnoMediaCollection.Server.csproj new file mode 100644 index 0000000..f5ba40b --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/UnoMediaCollection.Server.csproj @@ -0,0 +1,18 @@ + + + + net7.0 + true + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.Development.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Server/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/LinkerConfig.xml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/LinkerConfig.xml new file mode 100644 index 0000000..15068d5 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/LinkerConfig.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Program.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Program.cs new file mode 100644 index 0000000..ec6bdb3 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Program.cs @@ -0,0 +1,14 @@ +namespace UnoMediaCollection.Wasm +{ + public class Program + { + private static App? _app; + + public static int Main(string[] args) + { + Microsoft.UI.Xaml.Application.Start(_ => _app = new AppHead()); + + return 0; + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Properties/launchSettings.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Properties/launchSettings.json new file mode 100644 index 0000000..4f53e13 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:8080", + "sslPort": 0 + } + }, + "profiles": { + "UnoMediaCollection.Wasm": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5000", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj new file mode 100644 index 0000000..4d87fbb --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/UnoMediaCollection.Wasm.csproj @@ -0,0 +1,82 @@ + + + Exe + net7.0 + $(NoWarn);NU1504;NU1505;NU1701 + + disable + manifest.webmanifest + Properties + + / + + + true + $(DefineConstants);TRACE;DEBUG + portable + true + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmCSS/Fonts.css b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmCSS/Fonts.css new file mode 100644 index 0000000..4fdd605 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmCSS/Fonts.css @@ -0,0 +1,28 @@ +/** + When adding fonts here, make sure to add them using a base64 data uri, otherwise + fonts loading are delayed, and text may get displayed incorrectly. +*/ + +/* https://github.com/unoplatform/uno/issues/3954 */ +@font-face { + font-family: 'Segoe UI'; + src: local('Segoe UI'), local('-apple-system'), local('BlinkMacSystemFont'), local('Inter'), local('Cantarell'), local('Ubuntu'), local('Roboto'), local('Open Sans'), local('Noto Sans'), local('Helvetica Neue'), local('sans-serif'); +} + +@font-face { + font-family: 'Roboto'; + src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf) format('truetype'); + font-weight: 300; +} + +@font-face { + font-family: 'Roboto'; + src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf) format('truetype'); + font-weight: 400; +} + +@font-face { + font-family: 'Roboto'; + src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf) format('truetype'); + font-weight: 500; +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmScripts/AppManifest.js b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmScripts/AppManifest.js new file mode 100644 index 0000000..ac127a9 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/WasmScripts/AppManifest.js @@ -0,0 +1,3 @@ +var UnoAppManifest = { + displayName: "UnoMediaCollection" +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/manifest.webmanifest b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/manifest.webmanifest new file mode 100644 index 0000000..83500a2 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/manifest.webmanifest @@ -0,0 +1,10 @@ +{ + "background_color": "#ffffff", + "description": "UnoMediaCollection", + "display": "standalone", + "name": "UnoMediaCollection", + "short_name": "UnoMediaCollection", + "start_url": "/index.html", + "theme_color": "#ffffff", + "scope": "/" +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/staticwebapp.config.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/staticwebapp.config.json new file mode 100644 index 0000000..79c1b17 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/staticwebapp.config.json @@ -0,0 +1,30 @@ +{ + "navigationFallback": { + "rewrite": "/index.html", + "exclude": [ + "*.{css,js}", + "*.{png}", + "*.{c,h,wasm,clr,pdb,dat,txt}" + ] + }, + "routes": [ + { + "route": "/package_*", + "headers": { + "cache-control": "public, immutable, max-age=31536000" + } + }, + { + "route": "/*.ttf", + "headers": { + "cache-control": "public, immutable, max-age=31536000" + } + }, + { + "route": "/*", + "headers": { + "cache-control": "must-revalidate, max-age=3600" + } + } + ] +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/web.config b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/web.config new file mode 100644 index 0000000..8f5a860 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Wasm/wwwroot/web.config @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Package.appxmanifest b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Package.appxmanifest new file mode 100644 index 0000000..3c8be2c --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Package.appxmanifest @@ -0,0 +1,43 @@ + + + + + + + + UnoMediaCollection + UnoMediaCollection + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-arm64.pubxml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-arm64.pubxml new file mode 100644 index 0000000..1bfeb23 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-arm64.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + arm64 + win10-arm64 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x64.pubxml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x64.pubxml new file mode 100644 index 0000000..e6d3024 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x64.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + x64 + win10-x64 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x86.pubxml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x86.pubxml new file mode 100644 index 0000000..71540c0 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/PublishProfiles/win10-x86.pubxml @@ -0,0 +1,20 @@ + + + + + FileSystem + x86 + win10-x86 + bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\ + true + False + False + True + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/launchsettings.json b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/launchsettings.json new file mode 100644 index 0000000..a7612a4 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Properties/launchsettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "UnoMediaCollection.Windows (Package)": { + "commandName": "MsixPackage" + }, + "UnoMediaCollection.Windows (Unpackaged)": { + "commandName": "Project" + } + } +} diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Resources.lang-en-us.resw b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Resources.lang-en-us.resw new file mode 100644 index 0000000..fad04be --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/Resources.lang-en-us.resw @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Hello World! + + \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/UnoMediaCollection.Windows.csproj b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/UnoMediaCollection.Windows.csproj new file mode 100644 index 0000000..8fde8f6 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/UnoMediaCollection.Windows.csproj @@ -0,0 +1,84 @@ + + + WinExe + net7.0-windows10.0.19041.0 + 10.0.18362.0 + UnoMediaCollection.Windows + app.manifest + x86;x64;arm64 + win10-x86;win10-x64;win10-arm64 + win10-$(Platform).pubxml + true + true + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/app.manifest b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/app.manifest new file mode 100644 index 0000000..7faba96 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.Windows/app.manifest @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.sln b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.sln new file mode 100644 index 0000000..1316735 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection.sln @@ -0,0 +1,193 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34031.279 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{1E5A17EC-26C8-4A40-B290-6A00AA0C5A3A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Backend", "Backend", "{C42A4E85-37ED-4E96-BE55-496D88038529}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{638B6B93-222C-4ECC-972E-B712A68F9DA3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.DataContracts", "UnoMediaCollection.DataContracts\UnoMediaCollection.DataContracts.csproj", "{8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection", "UnoMediaCollection\UnoMediaCollection.csproj", "{79A87628-7E39-47A1-A004-1A010F9FB90F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.Base", "UnoMediaCollection.Base\UnoMediaCollection.Base.csproj", "{70D71625-0D4E-4D6F-A957-9BE6830FFDCA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.Mobile", "UnoMediaCollection.Mobile\UnoMediaCollection.Mobile.csproj", "{3B303C77-837D-4AB8-8F99-191444CE25E5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.Windows", "UnoMediaCollection.Windows\UnoMediaCollection.Windows.csproj", "{D335357B-3CC7-4017-AC05-8962F263E743}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.Wasm", "UnoMediaCollection.Wasm\UnoMediaCollection.Wasm.csproj", "{F0753AEE-AC72-4F21-87E6-DD5F46509C89}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnoMediaCollection.Server", "UnoMediaCollection.Server\UnoMediaCollection.Server.csproj", "{956E99B2-1A1F-4DD7-A436-3A604AF9C74E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E9CA951D-01DA-459C-9C62-FD8F9F569EDA}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + Directory.Build.props = Directory.Build.props + Directory.Build.targets = Directory.Build.targets + Directory.Packages.props = Directory.Packages.props + solution-config.props.sample = solution-config.props.sample + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|arm64 = Debug|arm64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|arm64 = Release|arm64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|arm64.ActiveCfg = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|arm64.Build.0 = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|x64.ActiveCfg = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|x64.Build.0 = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|x86.ActiveCfg = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Debug|x86.Build.0 = Debug|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|Any CPU.Build.0 = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|arm64.ActiveCfg = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|arm64.Build.0 = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|x64.ActiveCfg = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|x64.Build.0 = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|x86.ActiveCfg = Release|Any CPU + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7}.Release|x86.Build.0 = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|arm64.ActiveCfg = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|arm64.Build.0 = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|x64.ActiveCfg = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|x64.Build.0 = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|x86.ActiveCfg = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Debug|x86.Build.0 = Debug|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|Any CPU.Build.0 = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|arm64.ActiveCfg = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|arm64.Build.0 = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|x64.ActiveCfg = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|x64.Build.0 = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|x86.ActiveCfg = Release|Any CPU + {79A87628-7E39-47A1-A004-1A010F9FB90F}.Release|x86.Build.0 = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|arm64.ActiveCfg = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|arm64.Build.0 = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|x64.ActiveCfg = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|x64.Build.0 = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|x86.ActiveCfg = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Debug|x86.Build.0 = Debug|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|Any CPU.Build.0 = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|arm64.ActiveCfg = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|arm64.Build.0 = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|x64.ActiveCfg = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|x64.Build.0 = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|x86.ActiveCfg = Release|Any CPU + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA}.Release|x86.Build.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|arm64.ActiveCfg = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|arm64.Build.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|arm64.Deploy.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x64.ActiveCfg = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x64.Build.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x64.Deploy.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x86.ActiveCfg = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x86.Build.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Debug|x86.Deploy.0 = Debug|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|Any CPU.Build.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|Any CPU.Deploy.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|arm64.ActiveCfg = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|arm64.Build.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|arm64.Deploy.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x64.ActiveCfg = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x64.Build.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x64.Deploy.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x86.ActiveCfg = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x86.Build.0 = Release|Any CPU + {3B303C77-837D-4AB8-8F99-191444CE25E5}.Release|x86.Deploy.0 = Release|Any CPU + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|Any CPU.ActiveCfg = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|Any CPU.Build.0 = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|Any CPU.Deploy.0 = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|arm64.ActiveCfg = Debug|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|arm64.Build.0 = Debug|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|arm64.Deploy.0 = Debug|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x64.ActiveCfg = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x64.Build.0 = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x64.Deploy.0 = Debug|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x86.ActiveCfg = Debug|x86 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x86.Build.0 = Debug|x86 + {D335357B-3CC7-4017-AC05-8962F263E743}.Debug|x86.Deploy.0 = Debug|x86 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|Any CPU.ActiveCfg = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|Any CPU.Build.0 = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|Any CPU.Deploy.0 = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|arm64.ActiveCfg = Release|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|arm64.Build.0 = Release|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|arm64.Deploy.0 = Release|arm64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x64.ActiveCfg = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x64.Build.0 = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x64.Deploy.0 = Release|x64 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x86.ActiveCfg = Release|x86 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x86.Build.0 = Release|x86 + {D335357B-3CC7-4017-AC05-8962F263E743}.Release|x86.Deploy.0 = Release|x86 + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|arm64.ActiveCfg = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|arm64.Build.0 = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|x64.ActiveCfg = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|x64.Build.0 = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|x86.ActiveCfg = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Debug|x86.Build.0 = Debug|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|Any CPU.Build.0 = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|arm64.ActiveCfg = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|arm64.Build.0 = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|x64.ActiveCfg = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|x64.Build.0 = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|x86.ActiveCfg = Release|Any CPU + {F0753AEE-AC72-4F21-87E6-DD5F46509C89}.Release|x86.Build.0 = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|arm64.ActiveCfg = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|arm64.Build.0 = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|x64.ActiveCfg = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|x64.Build.0 = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|x86.ActiveCfg = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Debug|x86.Build.0 = Debug|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|Any CPU.Build.0 = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|arm64.ActiveCfg = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|arm64.Build.0 = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|x64.ActiveCfg = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|x64.Build.0 = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|x86.ActiveCfg = Release|Any CPU + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C42A4E85-37ED-4E96-BE55-496D88038529} = {1E5A17EC-26C8-4A40-B290-6A00AA0C5A3A} + {638B6B93-222C-4ECC-972E-B712A68F9DA3} = {1E5A17EC-26C8-4A40-B290-6A00AA0C5A3A} + {8A8DE7C3-B1E8-45D0-8400-68EE271F67B7} = {1E5A17EC-26C8-4A40-B290-6A00AA0C5A3A} + {79A87628-7E39-47A1-A004-1A010F9FB90F} = {1E5A17EC-26C8-4A40-B290-6A00AA0C5A3A} + {70D71625-0D4E-4D6F-A957-9BE6830FFDCA} = {638B6B93-222C-4ECC-972E-B712A68F9DA3} + {3B303C77-837D-4AB8-8F99-191444CE25E5} = {638B6B93-222C-4ECC-972E-B712A68F9DA3} + {D335357B-3CC7-4017-AC05-8962F263E743} = {638B6B93-222C-4ECC-972E-B712A68F9DA3} + {F0753AEE-AC72-4F21-87E6-DD5F46509C89} = {638B6B93-222C-4ECC-972E-B712A68F9DA3} + {956E99B2-1A1F-4DD7-A436-3A604AF9C74E} = {C42A4E85-37ED-4E96-BE55-496D88038529} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {789C2FEA-7BCF-4371-AB1A-B4D016140975} + EndGlobalSection +EndGlobal diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/App.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/App.cs new file mode 100644 index 0000000..b03c856 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/App.cs @@ -0,0 +1,108 @@ +using UnoMediaCollection.Interfaces; +using UnoMediaCollection.Services; +using UnoMediaCollection.ViewModels; + +namespace UnoMediaCollection +{ + public class App : Application + { + protected Window? MainWindow { get; private set; } + internal static IHost? HostContainer { get; private set; } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + var navigationService = new NavigationService(new Frame()); + navigationService.Configure(nameof(MainPage), typeof(MainPage)); + navigationService.Configure(nameof(ItemDetailsPage), typeof(ItemDetailsPage)); + + var builder = this.CreateBuilder(args) + .Configure(host => host +#if DEBUG + // Switch to Development environment when running in DEBUG + .UseEnvironment(Environments.Development) +#endif + .UseLogging(configure: (context, logBuilder) => + { + // Configure log levels for different categories of logging + logBuilder + .SetMinimumLevel( + context.HostingEnvironment.IsDevelopment() ? + LogLevel.Information : + LogLevel.Warning) + + // Default filters for core Uno Platform namespaces + .CoreLogLevel(LogLevel.Warning); + + // Uno Platform namespace filter groups + // Uncomment individual methods to see more detailed logging + //// Generic Xaml events + //logBuilder.XamlLogLevel(LogLevel.Debug); + //// Layout specific messages + //logBuilder.XamlLayoutLogLevel(LogLevel.Debug); + //// Storage messages + //logBuilder.StorageLogLevel(LogLevel.Debug); + //// Binding related messages + //logBuilder.XamlBindingLogLevel(LogLevel.Debug); + //// Binder memory references tracking + //logBuilder.BinderMemoryReferenceLogLevel(LogLevel.Debug); + //// RemoteControl and HotReload related + //logBuilder.HotReloadCoreLogLevel(LogLevel.Information); + //// Debug JS interop + //logBuilder.WebAssemblyLogLevel(LogLevel.Debug); + + }, enableUnoLogging: true) + .UseConfiguration(configure: configBuilder => + configBuilder + .EmbeddedSource() + .Section() + ) + // Register Json serializers (ISerializer and ISerializer) + .UseSerialization((context, services) => services + .AddContentSerializer(context) + .AddJsonTypeInfo(WeatherForecastContext.Default.IImmutableListWeatherForecast)) + .UseHttp((context, services) => services + // Register HttpClient +#if DEBUG + // DelegatingHandler will be automatically injected into Refit Client + .AddTransient() +#endif + .AddSingleton() + .AddRefitClient(context)) + .ConfigureServices((context, services) => + { + services.AddSingleton(navigationService); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + }) + ); + MainWindow = builder.Window; + + HostContainer = builder.Build(); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (MainWindow.Content is not Frame rootFrame) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + // Place the frame in the current Window + MainWindow.Content = rootFrame; + } + + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), args.Arguments); + } + + NavigationService.AppFrame = rootFrame; + + // Ensure the current window is active + MainWindow.Activate(); + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/AppResources.xaml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/AppResources.xaml new file mode 100644 index 0000000..d8cb54c --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/AppResources.xaml @@ -0,0 +1,13 @@ + + + + + + + + + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/Icons/back.svg b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/Icons/back.svg new file mode 100644 index 0000000..bcd7851 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/Icons/back.svg @@ -0,0 +1,3 @@ + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/SharedAssets.md b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/SharedAssets.md new file mode 100644 index 0000000..6d84997 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Assets/SharedAssets.md @@ -0,0 +1,34 @@ +See documentation about assets here : https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-assets.md + +# Here is a cheat sheet: + +1. Add the image file to the `Assets` directory of a shared project. +2. Set the build action to `Content`. +3. (Recommended) Provide an asset for various scales/dpi + +## Examples + +``` +\Assets\Images\logo.scale-100.png +\Assets\Images\logo.scale-200.png +\Assets\Images\logo.scale-400.png + +\Assets\Images\scale-100\logo.png +\Assets\Images\scale-200\logo.png +\Assets\Images\scale-400\logo.png +``` + +## Table of scales + +| Scale | UWP | iOS | Android | +|-------|:-----------:|:--------:|:-------:| +| `100` | scale-100 | @1x | mdpi | +| `125` | scale-125 | N/A | N/A | +| `150` | scale-150 | N/A | hdpi | +| `200` | scale-200 | @2x | xhdpi | +| `300` | scale-300 | @3x | xxhdpi | +| `400` | scale-400 | N/A | xxxhdpi | + + + + diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Business/Models/AppConfig.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Business/Models/AppConfig.cs new file mode 100644 index 0000000..9369eff --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Business/Models/AppConfig.cs @@ -0,0 +1,7 @@ +namespace UnoMediaCollection.Business.Models +{ + public record AppConfig + { + public string? Environment { get; init; } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/ItemType.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/ItemType.cs new file mode 100644 index 0000000..2cb89d7 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/ItemType.cs @@ -0,0 +1,9 @@ +namespace UnoMediaCollection.Enums +{ + public enum ItemType + { + Music, + Video, + Book + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/LocationType.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/LocationType.cs new file mode 100644 index 0000000..5220ead --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Enums/LocationType.cs @@ -0,0 +1,8 @@ +namespace UnoMediaCollection.Enums +{ + public enum LocationType + { + InCollection, + Loaned + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/GlobalUsings.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/GlobalUsings.cs new file mode 100644 index 0000000..a915a24 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/GlobalUsings.cs @@ -0,0 +1,22 @@ +global using CommunityToolkit.Mvvm.ComponentModel; +global using CommunityToolkit.Mvvm.Input; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Logging; +global using Microsoft.Extensions.Options; +global using Microsoft.UI.Xaml; +global using Microsoft.UI.Xaml.Controls; +global using Microsoft.UI.Xaml.Media; +global using Microsoft.UI.Xaml.Navigation; +global using System.Collections.Immutable; +global using System.Windows.Input; +global using UnoMediaCollection.Business.Models; +global using UnoMediaCollection.DataContracts; +global using UnoMediaCollection.DataContracts.Serialization; +global using UnoMediaCollection.Infrastructure; +global using UnoMediaCollection.Services.Caching; +global using UnoMediaCollection.Services.Endpoints; +global using Windows.ApplicationModel; +global using Windows.Networking.Connectivity; +global using Windows.Storage; +global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState; diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Infrastructure/DebugHandler.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Infrastructure/DebugHandler.cs new file mode 100644 index 0000000..93be6cd --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Infrastructure/DebugHandler.cs @@ -0,0 +1,42 @@ +namespace UnoMediaCollection.Infrastructure +{ + internal class DebugHttpHandler : DelegatingHandler + { + private readonly ILogger _logger; + + public DebugHttpHandler(ILogger logger, HttpMessageHandler? innerHandler = null) + : base(innerHandler ?? new HttpClientHandler()) + { + _logger = logger; + } + + protected async override Task SendAsync( + HttpRequestMessage request, + CancellationToken cancellationToken) + { + var response = await base.SendAsync(request, cancellationToken); +#if DEBUG + if(!response.IsSuccessStatusCode) + { + _logger.LogDebugMessage("Unsuccessful API Call"); + if(request.RequestUri is not null) + _logger.LogDebugMessage($"{request.RequestUri} ({request.Method})"); + foreach((var key, var values) in request.Headers.ToDictionary(x => x.Key, x => string.Join(", ", x.Value))) + { + _logger.LogDebugMessage($"{key}: {values}"); + } + + var content = request.Content is not null ? await request.Content.ReadAsStringAsync() : null; + if(!string.IsNullOrEmpty(content)) + { + _logger.LogDebugMessage(content); + } + + // Uncomment to automatically break when an API call fails while debugging + // System.Diagnostics.Debugger.Break(); + } +#endif + return response; + } + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/IDataService.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/IDataService.cs new file mode 100644 index 0000000..04db476 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/IDataService.cs @@ -0,0 +1,18 @@ +using UnoMediaCollection.Enums; +using UnoMediaCollection.Model; + +namespace UnoMediaCollection.Interfaces +{ + public interface IDataService + { + IList GetItems(); + MediaItem GetItem(int id); + int AddItem(MediaItem item); + void UpdateItem(MediaItem item); + IList GetItemTypes(); + Medium GetMedium(string name); + IList GetMediums(); + IList GetMediums(ItemType itemType); + IList GetLocationTypes(); + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/INavigationService.cs b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/INavigationService.cs new file mode 100644 index 0000000..3ecb81e --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/Interfaces/INavigationService.cs @@ -0,0 +1,12 @@ +using System; + +namespace UnoMediaCollection.Interfaces +{ + public interface INavigationService + { + string CurrentPage { get; } + void NavigateTo(string page); + void NavigateTo(string page, object parameter); + void GoBack(); + } +} \ No newline at end of file diff --git a/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ItemDetailsPage.xaml b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ItemDetailsPage.xaml new file mode 100644 index 0000000..6135490 --- /dev/null +++ b/Chapter13/Complete/UnoMediaCollection/UnoMediaCollection/ItemDetailsPage.xaml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +