diff --git a/templates/wpf/MyCompanyName.MyProjectName.sln b/templates/wpf/MyCompanyName.MyProjectName.sln new file mode 100644 index 0000000000..6110c63271 --- /dev/null +++ b/templates/wpf/MyCompanyName.MyProjectName.sln @@ -0,0 +1,21 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyCompanyName.MyProjectName", "src\MyCompanyName.MyProjectName\MyCompanyName.MyProjectName.csproj", "{7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{25D4C66E-2173-478D-ABBE-0E9FC0E93B57}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF} = {25D4C66E-2173-478D-ABBE-0E9FC0E93B57} + EndGlobalSection +EndGlobal diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml new file mode 100644 index 0000000000..7637433bab --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs new file mode 100644 index 0000000000..a4b134e32c --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/App.xaml.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Serilog; +using Serilog.Events; +using Volo.Abp; + +namespace MyCompanyName.MyProjectName +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private readonly IHost _host; + private readonly IAbpApplicationWithExternalServiceProvider _application; + + public App() + { + _host = Host + .CreateDefaultBuilder(null) + .UseAutofac() + .UseSerilog() + .ConfigureServices((hostContext, services) => + { + services.AddApplication(); + }).Build(); + _application = _host.Services.GetService(); + } + + protected override async void OnStartup(StartupEventArgs e) + { + Log.Logger = new LoggerConfiguration() +#if DEBUG + .MinimumLevel.Debug() +#else + .MinimumLevel.Information() +#endif + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) + .CreateLogger(); + + try + { + Log.Information("Starting wpf host."); + await _host.StartAsync(); + Initialize(_host.Services); + + _host.Services.GetService()?.Show(); + + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + } + finally + { + Log.CloseAndFlush(); + } + } + + protected override async void OnExit(ExitEventArgs e) + { + _application.Shutdown(); + await _host.StopAsync(); + _host.Dispose(); + } + + private void Initialize(IServiceProvider serviceProvider) + { + _application.Initialize(serviceProvider); + } + } +} diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/AssemblyInfo.cs b/templates/wpf/src/MyCompanyName.MyProjectName/AssemblyInfo.cs new file mode 100644 index 0000000000..4a05c7d474 --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] \ No newline at end of file diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/HelloWorldService.cs b/templates/wpf/src/MyCompanyName.MyProjectName/HelloWorldService.cs new file mode 100644 index 0000000000..d2d4275def --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/HelloWorldService.cs @@ -0,0 +1,12 @@ +using Volo.Abp.DependencyInjection; + + namespace MyCompanyName.MyProjectName +{ + public class HelloWorldService : ITransientDependency + { + public string SayHello() + { + return "Hello world!"; + } + } +} diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml b/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml new file mode 100644 index 0000000000..f716edebb5 --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml.cs b/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml.cs new file mode 100644 index 0000000000..be1004415d --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/MainWindow.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace MyCompanyName.MyProjectName +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private readonly HelloWorldService _helloWorldService; + + public MainWindow(HelloWorldService helloWorldService) + { + _helloWorldService = helloWorldService; + InitializeComponent(); + } + + protected override void OnContentRendered(EventArgs e) + { + HelloLabel.Content =_helloWorldService.SayHello(); + } + } +} diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj b/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj new file mode 100644 index 0000000000..d5fc98eb1d --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/MyCompanyName.MyProjectName.csproj @@ -0,0 +1,27 @@ + + + + WinExe + net5.0-windows + true + + + + + + + + + + + + + + + + + Always + + + + diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/MyProjectNameModule.cs b/templates/wpf/src/MyCompanyName.MyProjectName/MyProjectNameModule.cs new file mode 100644 index 0000000000..1687f50583 --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/MyProjectNameModule.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Autofac; +using Volo.Abp.Modularity; + +namespace MyCompanyName.MyProjectName +{ + [DependsOn(typeof(AbpAutofacModule))] + public class MyProjectNameModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddSingleton(); + } + } +} diff --git a/templates/wpf/src/MyCompanyName.MyProjectName/appsettings.json b/templates/wpf/src/MyCompanyName.MyProjectName/appsettings.json new file mode 100644 index 0000000000..d177980a92 --- /dev/null +++ b/templates/wpf/src/MyCompanyName.MyProjectName/appsettings.json @@ -0,0 +1,3 @@ +{ + +}