Browse Source

Update template

pull/12962/head
liangshiwei 4 years ago
parent
commit
9f94699bcb
  1. 10
      templates/maui/src/MyCompanyName.MyProjectName/MainPage.xaml.cs
  2. 15
      templates/maui/src/MyCompanyName.MyProjectName/MauiProgram.cs
  3. 10
      templates/maui/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj
  4. 4
      templates/maui/src/MyCompanyName.MyProjectName/MyProjectNameModule.cs
  5. 2
      templates/maui/src/MyCompanyName.MyProjectName/appsettings.json

10
templates/maui/src/MyCompanyName.MyProjectName/MainPage.xaml.cs

@ -1,6 +1,8 @@
namespace MyCompanyName.MyProjectName;
using Volo.Abp.DependencyInjection;
public partial class MainPage : ContentPage
namespace MyCompanyName.MyProjectName;
public partial class MainPage : ContentPage, ISingletonDependency
{
private readonly HelloWorldService _helloWorldService;
@ -18,8 +20,7 @@ public partial class MainPage : ContentPage
{
HelloLab.Text = _helloWorldService.SayHello();
}
private void OnCounterClicked(object sender, EventArgs e)
{
count++;
@ -32,4 +33,3 @@ public partial class MainPage : ContentPage
SemanticScreenReader.Announce(CounterBtn.Text);
}
}

15
templates/maui/src/MyCompanyName.MyProjectName/MauiProgram.cs

@ -1,6 +1,8 @@
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Volo.Abp;
using Volo.Abp.Autofac;
namespace MyCompanyName.MyProjectName;
@ -8,7 +10,6 @@ public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
@ -16,11 +17,13 @@ public static class MauiProgram
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});
})
.ConfigureContainer(new AbpAutofacServiceProviderFactory(new Autofac.ContainerBuilder()));
ConfigureConfiguration(builder);
builder.Services.AddApplication<MyProjectNameModule>(options =>
{
options.UseAutofac();
options.Services.ReplaceConfiguration(builder.Configuration);
});
@ -30,4 +33,10 @@ public static class MauiProgram
return app;
}
private static void ConfigureConfiguration(MauiAppBuilder builder)
{
var assembly = typeof(App).GetTypeInfo().Assembly;
builder.Configuration.AddJsonFile(new EmbeddedFileProvider(assembly), "appsettings.json", optional: false,false);
}
}

10
templates/maui/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj

@ -18,6 +18,7 @@
<!-- App Identifier -->
<ApplicationId>com.mycompanyname.myprojectname</ApplicationId>
<ApplicationIdGuid>27317750-B571-4690-B433-B358B2480E01</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
@ -34,6 +35,10 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.5" />
</ItemGroup>
<ItemGroup>
<!-- App Icon -->
@ -52,5 +57,10 @@
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<EmbeddedResource Include="appsettings.json" />
</ItemGroup>
</Project>

4
templates/maui/src/MyCompanyName.MyProjectName/MyProjectNameModule.cs

@ -6,8 +6,4 @@ namespace MyCompanyName.MyProjectName;
[DependsOn(typeof(AbpAutofacModule))]
public class MyProjectNameModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddTransient<MainPage>();
}
}

2
templates/maui/src/MyCompanyName.MyProjectName/appsettings.json

@ -1,3 +1,3 @@
{
"AppName": "MyProjectName"
}
Loading…
Cancel
Save