Skip to content

Commit b815a7c

Browse files
committed
basic MDM implementation for all platforms
1 parent edf038c commit b815a7c

37 files changed

Lines changed: 995 additions & 0 deletions
File renamed without changes.

XAM-MDM/MauiApp1/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:MauiApp1"
5+
x:Class="MauiApp1.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>

XAM-MDM/MauiApp1/App.xaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace MauiApp1;
2+
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
9+
MainPage = new AppShell();
10+
}
11+
}

XAM-MDM/MauiApp1/AppShell.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="MauiApp1.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:MauiApp1"
7+
Shell.FlyoutBehavior="Disabled">
8+
9+
<ShellContent
10+
Title="Home"
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>

XAM-MDM/MauiApp1/AppShell.xaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace MauiApp1;
2+
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}

XAM-MDM/MauiApp1/MainPage.xaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
x:Class="MauiApp1.MainPage">
5+
6+
<ScrollView>
7+
<VerticalStackLayout
8+
Spacing="25"
9+
Padding="30,0"
10+
VerticalOptions="Center">
11+
12+
<Image
13+
Source="intune.png"
14+
HeightRequest="100"
15+
HorizontalOptions="Center" />
16+
17+
<Label
18+
Text="ManagedConfiguration key 'MyMDMConfigKey' value"
19+
FontSize="20"
20+
HorizontalOptions="Center" />
21+
22+
<Label
23+
x:Name="lblConfig"
24+
Text=""
25+
FontSize="32"
26+
HorizontalOptions="Center" />
27+
28+
<Button
29+
x:Name="btnRefresh"
30+
Text="Refresh Managed Configuration"
31+
Clicked="OnBtnRefreshClicked"
32+
HorizontalOptions="Center" />
33+
34+
</VerticalStackLayout>
35+
</ScrollView>
36+
37+
</ContentPage>

XAM-MDM/MauiApp1/MainPage.xaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
namespace MauiApp1;
2+
3+
public partial class MainPage : ContentPage
4+
{
5+
public const string MyMDMConfigKey = "MyMDMConfigKey";
6+
7+
private readonly ManagedConfigurationProvider managedConfigurationProvider;
8+
9+
public MainPage()
10+
{
11+
InitializeComponent();
12+
13+
this.managedConfigurationProvider = new ManagedConfigurationProvider();
14+
}
15+
16+
protected override void OnAppearing()
17+
{
18+
base.OnAppearing();
19+
20+
lblConfig.Text = managedConfigurationProvider.GetStringValue(MyMDMConfigKey);
21+
}
22+
23+
private void OnBtnRefreshClicked(object sender, EventArgs e)
24+
{
25+
lblConfig.Text = managedConfigurationProvider.GetStringValue(MyMDMConfigKey);
26+
}
27+
}
28+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace MauiApp1
2+
{
3+
public partial class ManagedConfigurationProvider
4+
{
5+
public partial string GetStringValue(string key);
6+
}
7+
}

XAM-MDM/MauiApp1/MauiProgram.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Extensions.Logging;
2+
3+
namespace MauiApp1;
4+
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureFonts(fonts =>
13+
{
14+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
15+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
16+
});
17+
18+
#if DEBUG
19+
builder.Logging.AddDebug();
20+
#endif
21+
22+
return builder.Build();
23+
}
24+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
4+
<meta-data android:name="android.content.APP_RESTRICTIONS" android:resource="@xml/app_restrictions" />
5+
</application>
6+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
</manifest>

0 commit comments

Comments
 (0)