Browse Source

Merge branch 'appbuilder-avalonia'

pull/537/head
Steven Kirk 11 years ago
parent
commit
35d6513a88
  1. 95
      Avalonia.sln
  2. 12
      samples/BindingTest/App.xaml.cs
  3. 2
      samples/BindingTest/MainWindow.xaml.cs
  4. 26
      samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
  5. 39
      samples/ControlCatalog.Desktop/Program.cs
  6. 8
      samples/ControlCatalog.iOS/AppDelegate.cs
  7. 9
      samples/ControlCatalog/App.xaml.cs
  8. 4
      samples/ControlCatalog/MainWindow.xaml.cs
  9. 23
      samples/TestApplication/Program.cs
  10. 9
      samples/TestApplicationShared/App.cs
  11. 10
      samples/XamlTestApplication/Program.cs
  12. 4
      samples/XamlTestApplicationPcl/XamlTestApp.cs
  13. 144
      src/Avalonia.Controls/AppBuilder.cs
  14. 16
      src/Avalonia.Controls/Application.cs
  15. 1
      src/Avalonia.Controls/Avalonia.Controls.csproj
  16. 23
      src/Avalonia.DesignerSupport/DesignerAssist.cs
  17. 7
      src/Gtk/Avalonia.Cairo/CairoPlatform.cs
  18. 7
      src/Gtk/Avalonia.Gtk/GtkPlatform.cs
  19. 12
      src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs
  20. 7
      src/Skia/Avalonia.Skia/SkiaPlatform.cs
  21. 7
      src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
  22. 7
      src/Windows/Avalonia.Win32/Win32Platform.cs
  23. 19
      src/iOS/Avalonia.iOS/iOSPlatform.cs
  24. 9
      src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs
  25. 6
      tests/Avalonia.DesignerSupport.TestApp/App.config
  26. 6
      tests/Avalonia.DesignerSupport.TestApp/App.xaml
  27. 17
      tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs
  28. 153
      tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj
  29. 26
      tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.v2.ncrunchproject
  30. 5
      tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml
  31. 13
      tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml.cs
  32. 21
      tests/Avalonia.DesignerSupport.TestApp/Program.cs
  33. 36
      tests/Avalonia.DesignerSupport.TestApp/Properties/AssemblyInfo.cs
  34. 71
      tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.Designer.cs
  35. 117
      tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.resx
  36. 30
      tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.Designer.cs
  37. 7
      tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.settings
  38. 80
      tests/Avalonia.DesignerSupport.Tests/Avalonia.DesignerSupport.Tests.csproj
  39. 26
      tests/Avalonia.DesignerSupport.Tests/Avalonia.DesignerSupport.Tests.v2.ncrunchproject
  40. 85
      tests/Avalonia.DesignerSupport.Tests/Checker.cs
  41. 33
      tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs
  42. 36
      tests/Avalonia.DesignerSupport.Tests/Properties/AssemblyInfo.cs
  43. 9
      tests/Avalonia.DesignerSupport.Tests/packages.config
  44. 22
      tests/Avalonia.UnitTests/UnitTestApplication.cs

95
Avalonia.sln

@ -1,7 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14 # Visual Studio 14
VisualStudioVersion = 14.0.25123.0 VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Base", "src\Avalonia.Base\Avalonia.Base.csproj", "{B09B78D8-9B26-48B0-9149-D64A2F120F3F}"
EndProject EndProject
@ -153,11 +152,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ControlCatalog.iOS", "sampl
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.RenderTests", "tests\Avalonia.RenderTests\Avalonia.Skia.RenderTests.csproj", "{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Skia.RenderTests", "tests\Avalonia.RenderTests\Avalonia.Skia.RenderTests.csproj", "{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DesignerSupport.Tests", "tests\Avalonia.DesignerSupport.Tests\Avalonia.DesignerSupport.Tests.csproj", "{52F55355-D120-42AC-8116-8410A7D602FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DesignerSupport.TestApp", "tests\Avalonia.DesignerSupport.TestApp\Avalonia.DesignerSupport.TestApp.csproj", "{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}"
EndProject
Global Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{fb05ac90-89ba-4f2f-a924-f37875fb547c}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{fb05ac90-89ba-4f2f-a924-f37875fb547c}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13 src\Shared\PlatformSupport\PlatformSupport.projitems*{e4d9629c-f168-4224-3f51-a5e482ffbc42}*SharedItemsImports = 13
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{db070a10-bf39-4752-8456-86e9d5928478}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{db070a10-bf39-4752-8456-86e9d5928478}*SharedItemsImports = 4
@ -165,16 +166,12 @@ Global
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13 samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{ff69b927-c545-49ae-8e16-3d14d621aa12}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13 src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{811a76cf-1cf6-440f-963b-bbe31bd72a82}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4 src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{47be08a7-5985-410b-9ffc-2264b8ea595f}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{8c923867-8a8f-4f6b-8b80-47d9e8436166}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{e3a1060b-50d0-44e8-88b6-f44ef2e5bd72}*SharedItemsImports = 4 samples\TestApplicationShared\TestApplicationShared.projitems*{e3a1060b-50d0-44e8-88b6-f44ef2e5bd72}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{bd43f7c0-396b-4aa1-bad9-dfde54d51298}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4 src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{e1aa3dbf-9056-4530-9376-18119a7a3ffe}*SharedItemsImports = 4 src\Shared\PlatformSupport\PlatformSupport.projitems*{e1aa3dbf-9056-4530-9376-18119a7a3ffe}*SharedItemsImports = 4
EndGlobalSection EndGlobalSection
@ -1432,16 +1429,16 @@ Global
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.ActiveCfg = AppStore|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.Build.0 = AppStore|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|Any CPU.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhone.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.ActiveCfg = AppStore|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.ActiveCfg = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.Build.0 = AppStore|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.AppStore|x86.Build.0 = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.Build.0 = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|iPhone.ActiveCfg = Debug|Any CPU {47BE08A7-5985-410B-9FFC-2264B8EA595F}.Debug|iPhone.ActiveCfg = Debug|Any CPU
@ -1506,16 +1503,16 @@ Global
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.ActiveCfg = AppStore|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.Build.0 = AppStore|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|Any CPU.Build.0 = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhone.Build.0 = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.ActiveCfg = AppStore|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.ActiveCfg = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.Build.0 = AppStore|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.AppStore|x86.Build.0 = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.Build.0 = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|iPhone.ActiveCfg = Debug|Any CPU {4488AD85-1495-4809-9AA4-DDFE0A48527E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
@ -1836,6 +1833,70 @@ Global
{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.ActiveCfg = Release|Any CPU {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.ActiveCfg = Release|Any CPU
{D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.Build.0 = Release|Any CPU {D35A9F3D-8BB0-496E-BF72-444038A7DEBB}.Release|x86.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|Any CPU.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhone.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|x86.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.AppStore|x86.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhone.Build.0 = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|x86.ActiveCfg = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Debug|x86.Build.0 = Debug|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|Any CPU.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhone.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhone.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|x86.ActiveCfg = Release|Any CPU
{52F55355-D120-42AC-8116-8410A7D602FA}.Release|x86.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|Any CPU.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhone.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|x86.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.AppStore|x86.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhone.Build.0 = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|x86.ActiveCfg = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Debug|x86.Build.0 = Debug|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|Any CPU.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhone.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhone.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|x86.ActiveCfg = Release|Any CPU
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -1884,5 +1945,7 @@ Global
{2B888490-D14A-4BCA-AB4B-48676FA93C9B} = {9B9E3891-2366-4253-A952-D08BCEB71098} {2B888490-D14A-4BCA-AB4B-48676FA93C9B} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{57E0455D-D565-44BB-B069-EE1AA20F8337} = {9B9E3891-2366-4253-A952-D08BCEB71098} {57E0455D-D565-44BB-B069-EE1AA20F8337} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{D35A9F3D-8BB0-496E-BF72-444038A7DEBB} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {D35A9F3D-8BB0-496E-BF72-444038A7DEBB} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{52F55355-D120-42AC-8116-8410A7D602FA} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{F1381F98-4D24-409A-A6C5-1C5B1E08BB08} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

12
samples/BindingTest/App.xaml.cs

@ -1,7 +1,6 @@
using System; using System;
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Diagnostics;
using Avalonia.Logging.Serilog; using Avalonia.Logging.Serilog;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using Serilog; using Serilog;
@ -10,20 +9,19 @@ namespace BindingTest
{ {
public class App : Application public class App : Application
{ {
public App() public override void Initialize()
{ {
RegisterServices(); AvaloniaXamlLoader.Load(this);
} }
private static void Main() private static void Main()
{ {
InitializeLogging(); InitializeLogging();
new App() AppBuilder.Configure<App>()
.UseWin32() .UseWin32()
.UseDirect2D() .UseDirect2D1()
.LoadFromXaml() .Start<MainWindow>();
.RunWithMainWindow<MainWindow>();
} }
private static void InitializeLogging() private static void InitializeLogging()

2
samples/BindingTest/MainWindow.xaml.cs

@ -16,7 +16,7 @@ namespace BindingTest
private void InitializeComponent() private void InitializeComponent()
{ {
this.LoadFromXaml(); AvaloniaXamlLoader.Load(this);
} }
} }
} }

26
samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
@ -59,6 +59,10 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj">
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project>
<Name>Avalonia.DesignerSupport</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj"> <ProjectReference Include="..\..\src\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj">
<Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project> <Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project>
<Name>Avalonia.Cairo</Name> <Name>Avalonia.Cairo</Name>
@ -75,6 +79,10 @@
<Project>{6417E941-21BC-467B-A771-0DE389353CE6}</Project> <Project>{6417E941-21BC-467B-A771-0DE389353CE6}</Project>
<Name>Avalonia.Markup</Name> <Name>Avalonia.Markup</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Avalonia.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> <ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj">
<Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project> <Project>{B09B78D8-9B26-48B0-9149-D64A2F120F3F}</Project>
<Name>Avalonia.Base</Name> <Name>Avalonia.Base</Name>
@ -83,10 +91,26 @@
<Project>{D2221C82-4A25-4583-9B43-D791E3F6820C}</Project> <Project>{D2221C82-4A25-4583-9B43-D791E3F6820C}</Project>
<Name>Avalonia.Controls</Name> <Name>Avalonia.Controls</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj">
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project>
<Name>Avalonia.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Avalonia.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj">
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
<Name>Avalonia.Layout</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Logging.Serilog\Avalonia.Logging.Serilog.csproj"> <ProjectReference Include="..\..\src\Avalonia.Logging.Serilog\Avalonia.Logging.Serilog.csproj">
<Project>{B61B66A3-B82D-4875-8001-89D3394FE0C9}</Project> <Project>{B61B66A3-B82D-4875-8001-89D3394FE0C9}</Project>
<Name>Avalonia.Logging.Serilog</Name> <Name>Avalonia.Logging.Serilog</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.SceneGraph\Avalonia.SceneGraph.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Avalonia.SceneGraph</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> <ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj">
<Project>{F1BAA01A-F176-4C6A-B39D-5B40BB1B148F}</Project> <Project>{F1BAA01A-F176-4C6A-B39D-5B40BB1B148F}</Project>
<Name>Avalonia.Styling</Name> <Name>Avalonia.Styling</Name>

39
samples/ControlCatalog.Desktop/Program.cs

@ -1,10 +1,10 @@
using Avalonia.Logging.Serilog;
using Serilog;
using System; using System;
using System.Linq; using System.Linq;
using Avalonia; using Avalonia;
using System.Reflection; using Avalonia.Controls;
using Avalonia.Logging.Serilog;
using Avalonia.Platform; using Avalonia.Platform;
using Serilog;
namespace ControlCatalog namespace ControlCatalog
{ {
@ -14,10 +14,12 @@ namespace ControlCatalog
{ {
InitializeLogging(); InitializeLogging();
new App() // TODO: Make this work with GTK/Skia/Cairo depending on command-line args
.ConfigureRenderSystem(args) // again.
.LoadFromXaml() AppBuilder.Configure<App>()
.RunWithMainWindow<MainWindow>(); .UseWin32()
.UseDirect2D1()
.Start<MainWindow>();
} }
// This will be made into a runtime configuration extension soon! // This will be made into a runtime configuration extension soon!
@ -31,6 +33,12 @@ namespace ControlCatalog
#endif #endif
} }
private static void ConfigureAssetAssembly(AppBuilder builder)
{
AvaloniaLocator.CurrentMutable
.GetService<IAssetLoader>()
.SetDefaultAssembly(typeof(App).Assembly);
}
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -96,33 +104,32 @@ namespace ControlCatalog
/// <summary> /// <summary>
/// Selects the optimal render system for desktop platforms. Supports cmd line overrides /// Selects the optimal render system for desktop platforms. Supports cmd line overrides
/// </summary> /// </summary>
/// <param name="app"></param> /// <param name="builder"></param>
/// <param name="args"></param> /// <param name="args"></param>
public static TApp ConfigureRenderSystem<TApp>(this TApp app, string[] args) where TApp : Application public static AppBuilder ConfigureRenderSystem(this AppBuilder builder, string[] args)
{ {
// So this all works great under Windows where it can support // So this all works great under Windows where it can support
// ALL configurations. But on OSX/Unix we cannot use Direct2D // ALL configurations. But on OSX/Unix we cannot use Direct2D
//
if (args.Contains("--gtk") || DefaultRenderSystem() == RenderSystem.GTK) if (args.Contains("--gtk") || DefaultRenderSystem() == RenderSystem.GTK)
{ {
app.UseGtk(); builder.UseGtk();
app.UseCairo(); builder.UseCairo();
} }
else else
{ {
app.UseWin32(); builder.UseWin32();
if (args.Contains("--skia") || DefaultRenderSystem() == RenderSystem.Skia) if (args.Contains("--skia") || DefaultRenderSystem() == RenderSystem.Skia)
{ {
app.UseSkia(); builder.UseSkia();
} }
else else
{ {
app.UseDirect2D(); builder.UseDirect2D1();
} }
} }
return app; return builder;
} }
} }
} }

8
samples/ControlCatalog.iOS/AppDelegate.cs

@ -19,17 +19,13 @@ namespace ControlCatalog
// //
public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options)
{ {
new App() AppBuilder.Configure<App>()
.UseiOS() .UseiOS()
.UseSkiaViewHost() .UseSkiaViewHost()
.UseSkia() .UseSkia()
.UseAssetAssembly(typeof(App).Assembly) .Start<MainWindow>();
.LoadFromXaml()
.RunWithMainWindow<MainWindow>();
return true; return true;
} }
} }
} }

9
samples/ControlCatalog/App.xaml.cs

@ -1,16 +1,13 @@
using Avalonia; using Avalonia;
using Avalonia.Markup.Xaml;
namespace ControlCatalog namespace ControlCatalog
{ {
// Eventually we should move this into a PCL library so we can access
// from mobile platforms
//
public class App : Application public class App : Application
{ {
public App() public override void Initialize()
{ {
RegisterServices(); AvaloniaXamlLoader.Load(this);
} }
} }
} }

4
samples/ControlCatalog/MainWindow.xaml.cs

@ -19,9 +19,7 @@ namespace ControlCatalog
// now I am doing that here. But we need a better solution!! // now I am doing that here. But we need a better solution!!
var theme = new Avalonia.Themes.Default.DefaultTheme(); var theme = new Avalonia.Themes.Default.DefaultTheme();
theme.FindResource("Button"); theme.FindResource("Button");
AvaloniaXamlLoader.Load(this);
this.LoadFromXaml();
} }
} }
} }

23
samples/TestApplication/Program.cs

@ -34,25 +34,10 @@ namespace TestApplication
var app = new App(); var app = new App();
if (args.Contains("--gtk")) AppBuilder.Configure(app)
{ .UseWin32()
app.UseGtk(); .UseDirect2D1()
app.UseCairo(); .SetupWithoutStarting();
}
else
{
app.UseWin32();
// not available until we do the SkiaSharp merge
//if (args.Contains("--skia"))
//{
// app.UseSkia();
//}
//else
{
app.UseDirect2D();
}
}
app.Run(); app.Run();
} }

9
samples/TestApplicationShared/App.cs

@ -17,15 +17,6 @@ namespace TestApplication
{ {
public class App : Application public class App : Application
{ {
public App()
{
// TODO: I believe this has to happen before we select sub systems. Can we
// move this safely into Application itself? Is there anything in here
// that is platform specific??
//
RegisterServices();
}
public void Run() public void Run()
{ {
Styles.Add(new DefaultTheme()); Styles.Add(new DefaultTheme());

10
samples/XamlTestApplication/Program.cs

@ -7,6 +7,7 @@ using System.Windows.Threading;
using Avalonia; using Avalonia;
using Serilog; using Serilog;
using Avalonia.Logging.Serilog; using Avalonia.Logging.Serilog;
using Avalonia.Controls;
namespace XamlTestApplication namespace XamlTestApplication
{ {
@ -19,11 +20,10 @@ namespace XamlTestApplication
InitializeLogging(); InitializeLogging();
new XamlTestApp() AppBuilder.Configure<XamlTestApp>()
.UseWin32() .UseWin32()
.UseDirect2D() .UseDirect2D1()
.LoadFromXaml() .Start<Views.MainWindow>();
.RunWithMainWindow<Views.MainWindow>();
} }
private static void InitializeLogging() private static void InitializeLogging()

4
samples/XamlTestApplicationPcl/XamlTestApp.cs

@ -6,9 +6,9 @@ namespace XamlTestApplication
{ {
public class XamlTestApp : Application public class XamlTestApp : Application
{ {
public XamlTestApp() public override void Initialize()
{ {
RegisterServices(); AvaloniaXamlLoader.Load(this);
} }
} }
} }

144
src/Avalonia.Controls/AppBuilder.cs

@ -0,0 +1,144 @@
// Copyright (c) The Avalonia Project. All rights reserved.
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
namespace Avalonia.Controls
{
/// <summary>
/// Initializes up platform-specific services for an <see cref="Application"/>.
/// </summary>
public class AppBuilder
{
/// <summary>
/// Gets or sets the <see cref="Application"/> instance being initialized.
/// </summary>
public Application Instance { get; set; }
/// <summary>
/// Gets or sets a method to call the initialize the windowing subsystem.
/// </summary>
public Action WindowingSubsystem { get; set; }
/// <summary>
/// Gets or sets a method to call the initialize the windowing subsystem.
/// </summary>
public Action RenderingSubsystem { get; set; }
/// <summary>
/// Gets or sets a method to call before <see cref="Start{TMainWindow}"/> is called on the
/// <see cref="Application"/>.
/// </summary>
public Action<AppBuilder> BeforeStartCallback { get; set; }
/// <summary>
/// Begin configuring an <see cref="Application"/>.
/// </summary>
/// <typeparam name="TApp">The subclass of <see cref="Application"/> to configure.</typeparam>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public static AppBuilder Configure<TApp>()
where TApp : Application, new()
{
return Configure(new TApp());
}
/// <summary>
/// Begin configuring an <see cref="Application"/>.
/// </summary>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public static AppBuilder Configure(Application app)
{
AvaloniaLocator.CurrentMutable.BindToSelf(app);
return new AppBuilder()
{
Instance = app,
};
}
/// <summary>
/// Registers a callback to call before <see cref="Start{TMainWindow}"/> is called on the
/// <see cref="Application"/>.
/// </summary>
/// <param name="callback">The callback.</param>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public AppBuilder BeforeStarting(Action<AppBuilder> callback)
{
BeforeStartCallback = callback;
return this;
}
/// <summary>
/// Starts the application with an instance of <typeparamref name="TMainWindow"/>.
/// </summary>
/// <typeparam name="TMainWindow">The window type.</typeparam>
public void Start<TMainWindow>()
where TMainWindow : Window, new()
{
Setup();
BeforeStartCallback?.Invoke(this);
var window = new TMainWindow();
window.Show();
Instance.Run(window);
}
/// <summary>
/// Sets up the platform-specific services for the application, but does not run it.
/// </summary>
/// <returns></returns>
public AppBuilder SetupWithoutStarting()
{
Setup();
return this;
}
/// <summary>
/// Specifies a windowing subsystem to use.
/// </summary>
/// <param name="initializer">The method to call to initialize the windowing subsystem.</param>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public AppBuilder WithWindowingSubsystem(Action initializer)
{
WindowingSubsystem = initializer;
return this;
}
/// <summary>
/// Specifies a rendering subsystem to use.
/// </summary>
/// <param name="initializer">The method to call to initialize the rendering subsystem.</param>
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
public AppBuilder WithRenderingSubsystem(Action initializer)
{
RenderingSubsystem = initializer;
return this;
}
/// <summary>
/// Sets up the platform-speciic services for the <see cref="Application"/>.
/// </summary>
private void Setup()
{
if (Instance == null)
{
throw new InvalidOperationException("No App instance configured.");
}
if (WindowingSubsystem == null)
{
throw new InvalidOperationException("No windowing system configured.");
}
if (RenderingSubsystem == null)
{
throw new InvalidOperationException("No rendering system configured.");
}
Instance.RegisterServices();
WindowingSubsystem();
RenderingSubsystem();
Instance.Initialize();
}
}
}

16
src/Avalonia.Controls/Application.cs

@ -50,12 +50,6 @@ namespace Avalonia
/// </summary> /// </summary>
public Application() public Application()
{ {
if (Current != null)
{
throw new InvalidOperationException("Cannot create more than one Application instance.");
}
AvaloniaLocator.CurrentMutable.BindToSelf(this);
OnExit += OnExiting; OnExit += OnExiting;
} }
@ -132,6 +126,13 @@ namespace Avalonia
_platformInitializationCallback = cb; _platformInitializationCallback = cb;
} }
/// <summary>
/// Initializes the application by loading XAML etc.
/// </summary>
public virtual void Initialize()
{
}
/// <summary> /// <summary>
/// Runs the application's main loop until the <see cref="ICloseable"/> is closed. /// Runs the application's main loop until the <see cref="ICloseable"/> is closed.
/// </summary> /// </summary>
@ -165,13 +166,12 @@ namespace Avalonia
/// <param name="e"></param> /// <param name="e"></param>
protected virtual void OnExiting(object sender, EventArgs e) protected virtual void OnExiting(object sender, EventArgs e)
{ {
} }
/// <summary> /// <summary>
/// Register's the services needed by Avalonia. /// Register's the services needed by Avalonia.
/// </summary> /// </summary>
protected virtual void RegisterServices() public virtual void RegisterServices()
{ {
AvaloniaSynchronizationContext.InstallIfNeeded(); AvaloniaSynchronizationContext.InstallIfNeeded();
FocusManager = new FocusManager(); FocusManager = new FocusManager();

1
src/Avalonia.Controls/Avalonia.Controls.csproj

@ -43,6 +43,7 @@
<Compile Include="..\Shared\SharedAssemblyInfo.cs"> <Compile Include="..\Shared\SharedAssemblyInfo.cs">
<Link>Properties\SharedAssemblyInfo.cs</Link> <Link>Properties\SharedAssemblyInfo.cs</Link>
</Compile> </Compile>
<Compile Include="AppBuilder.cs" />
<Compile Include="Application.cs" /> <Compile Include="Application.cs" />
<Compile Include="Classes.cs" /> <Compile Include="Classes.cs" />
<Compile Include="ContextMenu.cs" /> <Compile Include="ContextMenu.cs" />

23
src/Avalonia.DesignerSupport/DesignerAssist.cs

@ -20,11 +20,8 @@ namespace Avalonia.DesignerSupport
{ {
class DesignerApp : Application class DesignerApp : Application
{ {
public DesignerApp() public override void Initialize()
{ {
RegisterServices();
//For now we only support windows
InitializeSubsystems(2);
Styles.Add(new DefaultTheme()); Styles.Add(new DefaultTheme());
var loader = new AvaloniaXamlLoader(); var loader = new AvaloniaXamlLoader();
@ -40,30 +37,32 @@ namespace Avalonia.DesignerSupport
{ {
Design.IsDesignMode = true; Design.IsDesignMode = true;
Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, SetScalingFactor = SetScalingFactor}; Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, SetScalingFactor = SetScalingFactor};
Application.RegisterPlatformCallback(Application.InitializeWin32Subsystem);
var plat = (IPclPlatformWrapper) Activator.CreateInstance(Assembly.Load(new AssemblyName("Avalonia.Win32")) var plat = (IPclPlatformWrapper) Activator.CreateInstance(Assembly.Load(new AssemblyName("Avalonia.Win32"))
.DefinedTypes.First(typeof (IPclPlatformWrapper).GetTypeInfo().IsAssignableFrom).AsType()); .DefinedTypes.First(typeof (IPclPlatformWrapper).GetTypeInfo().IsAssignableFrom).AsType());
TypeInfo app = null; TypeInfo app = null;
foreach (var asm in plat.GetLoadedAssemblies()) var asms = plat.GetLoadedAssemblies();
foreach (var asm in asms)
{ {
if(Equals(asm, typeof(Application).GetTypeInfo().Assembly)) if(Equals(asm, typeof(Application).GetTypeInfo().Assembly) || Equals(asm, typeof(DesignerApp).GetTypeInfo().Assembly))
continue; continue;
try try
{ {
app = asm.DefinedTypes.Where(typeof (Application).GetTypeInfo().IsAssignableFrom).FirstOrDefault(); app = asm.DefinedTypes.Where(typeof (Application).GetTypeInfo().IsAssignableFrom).FirstOrDefault();
if (app != null) if (app != null)
break; break;
} }
catch catch
{ {
//Ignore, Assembly.DefinedTypes threw an exception, we can't do anything about that //Ignore, Assembly.DefinedTypes threw an exception, we can't do anything about that
} }
} }
if (app == null)
new DesignerApp(); AppBuilder.Configure(app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType()))
else .WithWindowingSubsystem(Application.InitializeWin32Subsystem)
Activator.CreateInstance(app.AsType()); .WithRenderingSubsystem(() => { })
.SetupWithoutStarting();
} }
private static void SetScalingFactor(double factor) private static void SetScalingFactor(double factor)

7
src/Gtk/Avalonia.Cairo/CairoPlatform.cs

@ -6,15 +6,16 @@ using Avalonia.Cairo.Media;
using Avalonia.Cairo.Media.Imaging; using Avalonia.Cairo.Media.Imaging;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Controls;
namespace Avalonia namespace Avalonia
{ {
public static class GtkApplicationExtensions public static class GtkApplicationExtensions
{ {
public static TApp UseCairo<TApp>(this TApp app) where TApp : Application public static AppBuilder UseCairo(this AppBuilder builder)
{ {
Avalonia.Cairo.CairoPlatform.Initialize(); builder.RenderingSubsystem = Avalonia.Cairo.CairoPlatform.Initialize;
return app; return builder;
} }
} }
} }

7
src/Gtk/Avalonia.Gtk/GtkPlatform.cs

@ -9,15 +9,16 @@ using Avalonia.Input.Platform;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport; using Avalonia.Shared.PlatformSupport;
using Avalonia.Controls;
namespace Avalonia namespace Avalonia
{ {
public static class GtkApplicationExtensions public static class GtkApplicationExtensions
{ {
public static TApp UseGtk<TApp>(this TApp app) where TApp : Application public static AppBuilder UseGtk(this AppBuilder builder)
{ {
Avalonia.Gtk.GtkPlatform.Initialize(); builder.WindowingSubsystem = Avalonia.Gtk.GtkPlatform.Initialize;
return app; return builder;
} }
} }
} }

12
src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs

@ -223,15 +223,3 @@ namespace Avalonia.Markup.Xaml
} }
} }
} }
namespace Avalonia
{
public static class XamlObjectExtensions
{
public static TObject LoadFromXaml<TObject>(this TObject obj)
{
Markup.Xaml.AvaloniaXamlLoader.Load(obj);
return obj;
}
}
}

7
src/Skia/Avalonia.Skia/SkiaPlatform.cs

@ -1,16 +1,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Avalonia.Controls;
using Avalonia.Platform; using Avalonia.Platform;
namespace Avalonia namespace Avalonia
{ {
public static class SkiaApplicationExtensions public static class SkiaApplicationExtensions
{ {
public static TApp UseSkia<TApp>(this TApp app) where TApp : Application public static AppBuilder UseSkia(this AppBuilder builder)
{ {
Avalonia.Skia.SkiaPlatform.Initialize(); builder.RenderingSubsystem = Avalonia.Skia.SkiaPlatform.Initialize;
return app; return builder;
} }
} }
} }

7
src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs

@ -6,15 +6,16 @@ using System.IO;
using Avalonia.Direct2D1.Media; using Avalonia.Direct2D1.Media;
using Avalonia.Media; using Avalonia.Media;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Controls;
namespace Avalonia namespace Avalonia
{ {
public static class Direct2DApplicationExtensions public static class Direct2DApplicationExtensions
{ {
public static TApp UseDirect2D<TApp>(this TApp app) where TApp : Application public static AppBuilder UseDirect2D1(this AppBuilder builder)
{ {
Avalonia.Direct2D1.Direct2D1Platform.Initialize(); builder.RenderingSubsystem = Avalonia.Direct2D1.Direct2D1Platform.Initialize;
return app; return builder;
} }
} }
} }

7
src/Windows/Avalonia.Win32/Win32Platform.cs

@ -15,15 +15,16 @@ using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport; using Avalonia.Shared.PlatformSupport;
using Avalonia.Win32.Input; using Avalonia.Win32.Input;
using Avalonia.Win32.Interop; using Avalonia.Win32.Interop;
using Avalonia.Controls;
namespace Avalonia namespace Avalonia
{ {
public static class Win32ApplicationExtensions public static class Win32ApplicationExtensions
{ {
public static TApp UseWin32<TApp>(this TApp app) where TApp : Application public static AppBuilder UseWin32(this AppBuilder builder)
{ {
Avalonia.Win32.Win32Platform.Initialize(); builder.WindowingSubsystem = Avalonia.Win32.Win32Platform.Initialize;
return app; return builder;
} }
} }
} }

19
src/iOS/Avalonia.iOS/iOSPlatform.cs

@ -7,19 +7,20 @@ using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport; using Avalonia.Shared.PlatformSupport;
using Avalonia.Skia; using Avalonia.Skia;
using UIKit; using UIKit;
using Avalonia.Controls;
namespace Avalonia namespace Avalonia
{ {
public static class iOSApplicationExtensions public static class iOSApplicationExtensions
{ {
public static AppT UseiOS<AppT>(this AppT app) where AppT : Application public static AppBuilder UseiOS(this AppBuilder builder)
{ {
Avalonia.iOS.iOSPlatform.Initialize(); builder.WindowingSubsystem = Avalonia.iOS.iOSPlatform.Initialize;
return app; return builder;
} }
// TODO: Can we merge this with UseSkia somehow once HW/platform cleanup is done? // TODO: Can we merge this with UseSkia somehow once HW/platform cleanup is done?
public static AppT UseSkiaViewHost<AppT>(this AppT app) where AppT : Application public static AppBuilder UseSkiaViewHost(this AppBuilder builder)
{ {
var window = new UIWindow(UIScreen.MainScreen.Bounds); var window = new UIWindow(UIScreen.MainScreen.Bounds);
var controller = new AvaloniaViewController(window); var controller = new AvaloniaViewController(window);
@ -31,15 +32,7 @@ namespace Avalonia
SkiaPlatform.Initialize(); SkiaPlatform.Initialize();
return app; return builder;
}
public static AppT UseAssetAssembly<AppT>(this AppT app, Assembly assembly) where AppT : Application
{
// Asset loading searches our own assembly?
var loader = new AssetLoader(assembly);
AvaloniaLocator.CurrentMutable.Bind<IAssetLoader>().ToConstant(loader);
return app;
} }
} }
} }

9
src/iOS/Avalonia.iOSTestApplication/AppDelegate.cs

@ -27,13 +27,14 @@ namespace Avalonia.iOSTestApplication
// //
public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options) public override bool FinishedLaunching(UIApplication uiapp, NSDictionary options)
{ {
var app = new App() var app = new App();
AppBuilder.Configure(app)
.UseiOS() .UseiOS()
.UseSkiaViewHost() .UseSkiaViewHost()
.UseSkia(); .UseSkia()
.SetupWithoutStarting();
var asm = typeof(App).Assembly;
app.UseAssetAssembly(asm);
app.Run(); app.Run();
return true; return true;

6
tests/Avalonia.DesignerSupport.TestApp/App.config

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>

6
tests/Avalonia.DesignerSupport.TestApp/App.xaml

@ -0,0 +1,6 @@
<Application xmlns="https://github.com/avaloniaui">
<Application.Styles>
<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/>
</Application.Styles>
</Application>

17
tests/Avalonia.DesignerSupport.TestApp/App.xaml.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Markup.Xaml;
namespace Avalonia.DesignerSupport.TestApp
{
public class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
}
}

153
tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F1381F98-4D24-409A-A6C5-1C5B1E08BB08}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.DesignerSupport.TestApp</RootNamespace>
<AssemblyName>Avalonia.DesignerSupport.TestApp</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Avalonia.Animation</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj">
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project>
<Name>Avalonia.Base</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj">
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project>
<Name>Avalonia.Controls</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj">
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project>
<Name>Avalonia.DesignerSupport</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj">
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project>
<Name>Avalonia.Input</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj">
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project>
<Name>Avalonia.Interactivity</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj">
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project>
<Name>Avalonia.Layout</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.SceneGraph\Avalonia.SceneGraph.csproj">
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project>
<Name>Avalonia.SceneGraph</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj">
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project>
<Name>Avalonia.Styling</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj">
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project>
<Name>Avalonia.Themes.Default</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj">
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project>
<Name>Avalonia.Markup.Xaml</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj">
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project>
<Name>Avalonia.Markup</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj">
<Project>{3e908f67-5543-4879-a1dc-08eace79b3cd}</Project>
<Name>Avalonia.Direct2D1</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Windows\Avalonia.Win32\Avalonia.Win32.csproj">
<Project>{811a76cf-1cf6-440f-963b-bbe31bd72a82}</Project>
<Name>Avalonia.Win32</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

26
tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.v2.ncrunchproject

@ -0,0 +1,26 @@
<ProjectConfiguration>
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies>
<BuildPriority>1000</BuildPriority>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>

5
tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml

@ -0,0 +1,5 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:pages="clr-namespace:ControlCatalog.Pages;assembly=ControlCatalog"
Title="TESTAPP">
<Button/>
</Window>

13
tests/Avalonia.DesignerSupport.TestApp/MainWindow.xaml.cs

@ -0,0 +1,13 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Avalonia.DesignerSupport.TestApp
{
public class MainWindow : Window
{
public MainWindow()
{
AvaloniaXamlLoader.Load(this);
}
}
}

21
tests/Avalonia.DesignerSupport.TestApp/Program.cs

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Avalonia.Controls;
namespace Avalonia.DesignerSupport.TestApp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
AppBuilder.Configure<App>().UseDirect2D1().UseWin32().Start<MainWindow>();
}
}
}

36
tests/Avalonia.DesignerSupport.TestApp/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Avalonia.DesignerSupport.TestApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Avalonia.DesignerSupport.TestApp")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f1381f98-4d24-409a-a6c5-1c5b1e08bb08")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

71
tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.Designer.cs

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Avalonia.DesignerSupport.TestApp.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Avalonia.DesignerSupport.TestApp.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

117
tests/Avalonia.DesignerSupport.TestApp/Properties/Resources.resx

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

30
tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.Designer.cs

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Avalonia.DesignerSupport.TestApp.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

7
tests/Avalonia.DesignerSupport.TestApp/Properties/Settings.settings

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

80
tests/Avalonia.DesignerSupport.Tests/Avalonia.DesignerSupport.Tests.csproj

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{52F55355-D120-42AC-8116-8410A7D602FA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.DesignerSupport.Tests</RootNamespace>
<AssemblyName>Avalonia.DesignerSupport.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\src\Avalonia.DesignerSupport\DesignerApi.cs">
<Link>DesignerApi.cs</Link>
</Compile>
<Compile Include="Checker.cs" />
<Compile Include="DesignerSupportTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

26
tests/Avalonia.DesignerSupport.Tests/Avalonia.DesignerSupport.Tests.v2.ncrunchproject

@ -0,0 +1,26 @@
<ProjectConfiguration>
<AutoDetectNugetBuildDependencies>true</AutoDetectNugetBuildDependencies>
<BuildPriority>1000</BuildPriority>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<AllowCodeAnalysis>false</AllowCodeAnalysis>
<IgnoreThisComponentCompletely>true</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<DetectStackOverflow>true</DetectStackOverflow>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform></UseBuildPlatform>
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>

85
tests/Avalonia.DesignerSupport.Tests/Checker.cs

@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.DesignerSupport.Tests
{
public class Checker : MarshalByRefObject
{
private string _appDir;
private IntPtr _window;
public void DoCheck(string outputDir, string xamlText)
{
_appDir = Path.GetFullPath(outputDir);
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
foreach (var asm in Directory.GetFiles(_appDir).Where(f => f.ToLower().EndsWith(".dll") || f.ToLower().EndsWith(".exe")))
try
{
Assembly.LoadFrom(asm);
}
catch (Exception e)
{
}
var dic = new Dictionary<string, object>();
var api = new DesignerApi(dic) { OnResize = OnResize, OnWindowCreated = OnWindowCreated };
LookupStaticMethod("Avalonia.DesignerSupport.DesignerAssist", "Init").Invoke(null, new object[] { dic });
api.UpdateXaml(xamlText);
if (_window == IntPtr.Zero)
throw new Exception("Something went wrong");
SendMessage(_window, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public const uint WM_CLOSE = 0x0010;
private void OnWindowCreated(IntPtr lastIntPtr)
{
_window = lastIntPtr;
}
private void OnResize()
{
}
static Type LookupType(params string[] names)
{
var asms = AppDomain.CurrentDomain.GetAssemblies();
foreach (var asm in asms)
{
foreach (var name in names)
{
var found = asm.GetType(name, false, true);
if (found != null)
return found;
}
}
throw new TypeLoadException("Unable to find any of types: " + string.Join(",", names));
}
static MethodInfo LookupStaticMethod(string typeName, string method)
{
var type = LookupType(typeName);
var methods = type.GetMethods();
return methods.First(m => m.Name == method);
}
private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assemblyPath = Path.Combine(_appDir, new AssemblyName(args.Name).Name + ".dll");
if (File.Exists(assemblyPath) == false) return null;
Assembly assembly = Assembly.LoadFrom(assemblyPath);
return assembly;
}
}
}

33
tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Xunit.Extensions;
namespace Avalonia.DesignerSupport.Tests
{
public class DesignerSupportTests
{
[Theory,
InlineData(@"..\..\..\Avalonia.DesignerSupport.TestApp\bin\$BUILD", @"..\..\..\Avalonia.DesignerSupport.TestApp\MainWindow.xaml"),
InlineData(@"..\..\..\..\samples\ControlCatalog.Desktop\bin\$BUILD", @"..\..\..\..\samples\ControlCatalog\MainWindow.xaml")]
public void DesgignerApiShoudBeOperational(string outputDir, string xamlFile)
{
var xaml = File.ReadAllText(xamlFile);
#if DEBUG
outputDir = outputDir.Replace("$BUILD", "Debug");
#else
outputDir = outputDir.Replace("$BUILD", "Release");
#endif
var domain = AppDomain.CreateDomain("TESTDOMAIN" + Guid.NewGuid());
var checker = (Checker)domain.CreateInstanceFromAndUnwrap(typeof (Checker).Assembly.GetModules()[0].FullyQualifiedName,
"Avalonia.DesignerSupport.Tests.Checker");
checker.DoCheck(outputDir, xaml);
}
}
}

36
tests/Avalonia.DesignerSupport.Tests/Properties/AssemblyInfo.cs

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Avalonia.DesignerSupport.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Avalonia.DesignerSupport.Tests")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("52f55355-d120-42ac-8116-8410a7d602fa")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

9
tests/Avalonia.DesignerSupport.Tests/packages.config

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.1.0" targetFramework="net46" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net46" />
<package id="xunit.assert" version="2.1.0" targetFramework="net46" />
<package id="xunit.core" version="2.1.0" targetFramework="net46" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net46" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net46" />
</packages>

22
tests/Avalonia.UnitTests/UnitTestApplication.cs

@ -12,31 +12,27 @@ namespace Avalonia.UnitTests
{ {
public class UnitTestApplication : Application public class UnitTestApplication : Application
{ {
private readonly TestServices _services;
public UnitTestApplication(TestServices services) public UnitTestApplication(TestServices services)
{ {
Services = services ?? new TestServices(); _services = services ?? new TestServices();
RegisterServices(); RegisterServices();
var styles = Services.Theme?.Invoke();
if (styles != null)
{
Styles.AddRange(styles);
}
} }
public static new UnitTestApplication Current => (UnitTestApplication)Application.Current; public static new UnitTestApplication Current => (UnitTestApplication)Application.Current;
public TestServices Services { get; } public TestServices Services => _services;
public static IDisposable Start(TestServices services = null) public static IDisposable Start(TestServices services = null)
{ {
var scope = AvaloniaLocator.EnterScope(); var scope = AvaloniaLocator.EnterScope();
var app = new UnitTestApplication(services); var app = new UnitTestApplication(services);
AvaloniaLocator.CurrentMutable.BindToSelf<Application>(app);
return scope; return scope;
} }
protected override void RegisterServices() public override void RegisterServices()
{ {
AvaloniaLocator.CurrentMutable AvaloniaLocator.CurrentMutable
.Bind<IAssetLoader>().ToConstant(Services.AssetLoader) .Bind<IAssetLoader>().ToConstant(Services.AssetLoader)
@ -52,6 +48,12 @@ namespace Avalonia.UnitTests
.Bind<IStyler>().ToConstant(Services.Styler) .Bind<IStyler>().ToConstant(Services.Styler)
.Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform) .Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform)
.Bind<IApplicationLifecycle>().ToConstant(this); .Bind<IApplicationLifecycle>().ToConstant(this);
var styles = Services.Theme?.Invoke();
if (styles != null)
{
Styles.AddRange(styles);
}
} }
} }
} }

Loading…
Cancel
Save