Browse Source

Moved IPclPlatformWrapper and IAssetLoader to a separate assembly

pull/703/head
Nikita Tsukanov 10 years ago
parent
commit
3af869f49f
  1. 40
      Avalonia.DotNetFrameworkRuntime/AppBuilder.cs
  2. 81
      Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj
  3. 36
      Avalonia.DotNetFrameworkRuntime/Properties/AssemblyInfo.cs
  4. 5
      Avalonia.DotNetFrameworkRuntime/packages.config
  5. 45
      Avalonia.sln
  6. 4
      samples/BindingTest/BindingTest.csproj
  7. 8
      samples/ControlCatalog.Desktop/App.config
  8. 4
      samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj
  9. 4
      samples/TestApplication/TestApplication.csproj
  10. 8
      samples/VirtualizationTest/App.config
  11. 4
      samples/VirtualizationTest/VirtualizationTest.csproj
  12. 4
      samples/XamlTestApplication/XamlTestApplication.csproj
  13. 2
      src/Android/Avalonia.Android/AndroidPlatform.cs
  14. 2
      src/Avalonia.Base/Avalonia.Base.csproj
  15. 2
      src/Avalonia.Base/AvaloniaDisposable.cs
  16. 2
      src/Avalonia.Base/Platform/IRuntimePlatform.cs
  17. 4
      src/Avalonia.Base/Threading/SingleThreadDispatcher.cs
  18. 54
      src/Avalonia.Controls/AppBuilder.cs
  19. 14
      src/Avalonia.DesignerSupport/DesignerAssist.cs
  20. 2
      src/Gtk/Avalonia.Cairo/CairoPlatform.cs
  21. 1
      src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj
  22. 4
      src/Gtk/Avalonia.Gtk/GtkPlatform.cs
  23. 2
      src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs
  24. 6
      src/Shared/PlatformSupport/PlatformSupport.projitems
  25. 4
      src/Shared/PlatformSupport/StandardRuntimePlatform.cs
  26. 4
      src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs
  27. 2
      src/Skia/Avalonia.Skia/SkiaPlatform.cs
  28. 2
      src/Windows/Avalonia.Direct2D1/Direct2D1Platform.cs
  29. 1
      src/Windows/Avalonia.Win32/Avalonia.Win32.csproj
  30. 6
      src/Windows/Avalonia.Win32/Win32Platform.cs
  31. 6
      src/iOS/Avalonia.iOS/iOSPlatform.cs
  32. 4
      tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj
  33. 2
      tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs
  34. 14
      tests/Avalonia.UnitTests/TestServices.cs
  35. 2
      tests/Avalonia.UnitTests/UnitTestApplication.cs

40
Avalonia.DotNetFrameworkRuntime/AppBuilder.cs

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport;
namespace Avalonia
{
public sealed class AppBuilder : AppBuilderBase<AppBuilder>
{
public AppBuilder() : base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register())
{
}
public AppBuilder(Application app) : this()
{
Instance = app;
}
public AppBuilder UsePlatformDetect()
{
var platformId = (int)Environment.OSVersion.Platform;
if (platformId == 4 || platformId == 6)
{
UseRenderingSubsystem("Avalonia.Cairo");
UseWindowingSubsystem("Avalonia.Gtk");
}
else
{
UseRenderingSubsystem("Avalonia.Direct2D1");
UseWindowingSubsystem("Avalonia.Win32");
}
return this;
}
}
}

81
Avalonia.DotNetFrameworkRuntime/Avalonia.DotNetFrameworkRuntime.csproj

@ -0,0 +1,81 @@
<?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>{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Avalonia.DotNetFrameworkRuntime</RootNamespace>
<AssemblyName>Avalonia.DotNetFrameworkRuntime</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</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.Reactive.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Core.3.0.0\lib\net45\System.Reactive.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reactive.Interfaces.3.0.0\lib\net45\System.Reactive.Interfaces.dll</HintPath>
<Private>True</Private>
</Reference>
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppBuilder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<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.Styling\Avalonia.Styling.csproj">
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project>
<Name>Avalonia.Styling</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\src\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" />
<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>

36
Avalonia.DotNetFrameworkRuntime/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.DotNetFrameworkRuntime")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Avalonia.DotNetFrameworkRuntime")]
[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("4a1abb09-9047-4bd5-a4ad-a055e52c5ee0")]
// 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")]

5
Avalonia.DotNetFrameworkRuntime/packages.config

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Reactive.Core" version="3.0.0" targetFramework="net45" />
<package id="System.Reactive.Interfaces" version="3.0.0" targetFramework="net45" />
</packages>

45
Avalonia.sln

@ -163,6 +163,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Avalonia.RenderTests", "tes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VirtualizationTest", "samples\VirtualizationTest\VirtualizationTest.csproj", "{FBCAF3D0-2808-4934-8E96-3F607594517B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.DotNetFrameworkRuntime", "Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj", "{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Skia\Avalonia.Skia\Avalonia.Skia.projitems*{2f59f3d0-748d-4652-b01e-e0d954756308}*SharedItemsImports = 13
@ -172,10 +174,9 @@ Global
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
tests\Avalonia.RenderTests\Avalonia.RenderTests.projitems*{48840edd-24bf-495d-911e-2eb12ae75d3b}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{54f237d5-a70a-4752-9656-0c70b1a7b047}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}*SharedItemsImports = 4
samples\TestApplicationShared\TestApplicationShared.projitems*{78345174-5b52-4a14-b9fd-d5f2428137f0}*SharedItemsImports = 13
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*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
samples\TestApplicationShared\TestApplicationShared.projitems*{8c923867-8a8f-4f6b-8b80-47d9e8436166}*SharedItemsImports = 4
src\Shared\RenderHelpers\RenderHelpers.projitems*{925dd807-b651-475f-9f7c-cbeb974ce43d}*SharedItemsImports = 4
@ -2242,6 +2243,46 @@ Global
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|Mono.Build.0 = Release|Any CPU
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.ActiveCfg = Release|Any CPU
{FBCAF3D0-2808-4934-8E96-3F607594517B}.Release|x86.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhone.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|iPhoneSimulator.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Mono.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|Mono.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Ad-Hoc|x86.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Any CPU.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Any CPU.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhone.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhone.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Mono.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|Mono.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|x86.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.AppStore|x86.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhone.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Mono.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|Mono.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Any CPU.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhone.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhone.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Mono.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Mono.Build.0 = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|x86.ActiveCfg = Release|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

4
samples/BindingTest/BindingTest.csproj

@ -93,6 +93,10 @@
<EmbeddedResource Include="TestItemView.xaml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</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>

8
samples/ControlCatalog.Desktop/App.config

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

4
samples/ControlCatalog.Desktop/ControlCatalog.Desktop.csproj

@ -60,6 +60,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.DesignerSupport\Avalonia.DesignerSupport.csproj">
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project>
<Name>Avalonia.DesignerSupport</Name>

4
samples/TestApplication/TestApplication.csproj

@ -83,6 +83,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Gtk\Avalonia.Cairo\Avalonia.Cairo.csproj">
<Project>{FB05AC90-89BA-4F2F-A924-F37875FB547C}</Project>
<Name>Avalonia.Cairo</Name>

8
samples/VirtualizationTest/App.config

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

4
samples/VirtualizationTest/VirtualizationTest.csproj

@ -83,6 +83,10 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Avalonia.Animation</Name>

4
samples/XamlTestApplication/XamlTestApplication.csproj

@ -91,6 +91,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj">
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project>
<Name>Avalonia.Markup</Name>

2
src/Android/Avalonia.Android/AndroidPlatform.cs

@ -49,7 +49,7 @@ namespace Avalonia.Android
public void Init(Type applicationType)
{
SharedPlatform.Register(applicationType.Assembly);
StandardRuntimePlatformServices.Register(applicationType.Assembly);
}
public IWindowImpl CreateWindow()

2
src/Avalonia.Base/Avalonia.Base.csproj

@ -85,7 +85,7 @@
<Compile Include="AvaloniaPropertyRegistry.cs" />
<Compile Include="AvaloniaProperty`1.cs" />
<Compile Include="Platform\IAssetLoader.cs" />
<Compile Include="Platform\IPclPlatformWrapper.cs" />
<Compile Include="Platform\IRuntimePlatform.cs" />
<Compile Include="Data\BindingPriority.cs" />
<Compile Include="PriorityBindingEntry.cs" />
<Compile Include="Collections\IAvaloniaList.cs" />

2
src/Avalonia.Base/AvaloniaDisposable.cs

@ -20,7 +20,7 @@ namespace Avalonia
{
IsDisposed = true;
#if DEBUG_DISPOSE
DisposedAt = AvaloniaLocator.Current.GetService<IPclPlatformWrapper>().GetStackTrace();
DisposedAt = AvaloniaLocator.Current.GetService<IRuntimePlatform>().GetStackTrace();
#endif
DoDispose();
}

2
src/Avalonia.Base/Platform/IPclPlatformWrapper.cs → src/Avalonia.Base/Platform/IRuntimePlatform.cs

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Avalonia.Platform
{
public interface IPclPlatformWrapper
public interface IRuntimePlatform
{
Assembly[] GetLoadedAssemblies();
void PostThreadPoolItem(Action cb);

4
src/Avalonia.Base/Threading/SingleThreadDispatcher.cs

@ -33,7 +33,7 @@ namespace Avalonia.Threading
}
public IDisposable StartTimer(TimeSpan interval, Action tick)
=> AvaloniaLocator.Current.GetService<IPclPlatformWrapper>().StartSystemTimer(interval,
=> AvaloniaLocator.Current.GetService<IRuntimePlatform>().StartSystemTimer(interval,
() => _timerJobRunner.Post(tick, DispatcherPriority.Normal));
public void Signal() => _evnt.Set();
@ -50,7 +50,7 @@ namespace Avalonia.Threading
public static Dispatcher StartNew(CancellationToken token)
{
var dispatcher = new SingleThreadDispatcher();
AvaloniaLocator.Current.GetService<IPclPlatformWrapper>().PostThreadPoolItem(() =>
AvaloniaLocator.Current.GetService<IRuntimePlatform>().PostThreadPoolItem(() =>
{
dispatcher.MainLoop(token);
});

54
src/Avalonia.Controls/AppBuilder.cs

@ -3,14 +3,25 @@
using System;
using System.Reflection;
using Avalonia.Platform;
namespace Avalonia.Controls
{
/// <summary>
/// Initializes up platform-specific services for an <see cref="Application"/>.
/// </summary>
public class AppBuilder
public abstract class AppBuilderBase<AppBuilder> where AppBuilder : AppBuilderBase<AppBuilder>, new()
{
/// <summary>
/// Gets or sets the <see cref="IRuntimePlatform"/> instance.
/// </summary>
public IRuntimePlatform RuntimePlatform { get; set; }
/// <summary>
/// Gets or sets a method to call the initialize the runtime platform services (e. g. AssetLoader)
/// </summary>
public Action RuntimePlatformServices { get; set; }
/// <summary>
/// Gets or sets the <see cref="Application"/> instance being initialized.
/// </summary>
@ -32,6 +43,12 @@ namespace Avalonia.Controls
/// </summary>
public Action<AppBuilder> BeforeStartCallback { get; set; }
protected AppBuilderBase(IRuntimePlatform platform, Action platformSevices)
{
RuntimePlatform = platform;
RuntimePlatformServices = platformSevices;
}
/// <summary>
/// Begin configuring an <see cref="Application"/>.
/// </summary>
@ -57,6 +74,8 @@ namespace Avalonia.Controls
};
}
protected AppBuilder Self => (AppBuilder) this;
/// <summary>
/// Registers a callback to call before <see cref="Start{TMainWindow}"/> is called on the
/// <see cref="Application"/>.
@ -66,7 +85,7 @@ namespace Avalonia.Controls
public AppBuilder BeforeStarting(Action<AppBuilder> callback)
{
BeforeStartCallback = callback;
return this;
return Self;
}
/// <summary>
@ -77,7 +96,7 @@ namespace Avalonia.Controls
where TMainWindow : Window, new()
{
Setup();
BeforeStartCallback?.Invoke(this);
BeforeStartCallback?.Invoke(Self);
var window = new TMainWindow();
window.Show();
@ -91,7 +110,7 @@ namespace Avalonia.Controls
public AppBuilder SetupWithoutStarting()
{
Setup();
return this;
return Self;
}
/// <summary>
@ -102,7 +121,7 @@ namespace Avalonia.Controls
public AppBuilder UseWindowingSubsystem(Action initializer)
{
WindowingSubsystem = initializer;
return this;
return Self;
}
/// <summary>
@ -120,7 +139,7 @@ namespace Avalonia.Controls
public AppBuilder UseRenderingSubsystem(Action initializer)
{
RenderingSubsystem = initializer;
return this;
return Self;
}
/// <summary>
@ -140,23 +159,6 @@ namespace Avalonia.Controls
init.Invoke(null, null);
};
public AppBuilder UsePlatformDetect()
{
var platformId = (int)
((dynamic) Type.GetType("System.Environment").GetRuntimeProperty("OSVersion").GetValue(null)).Platform;
if (platformId == 4 || platformId == 6)
{
UseRenderingSubsystem("Avalonia.Cairo");
UseWindowingSubsystem("Avalonia.Gtk");
}
else
{
UseRenderingSubsystem("Avalonia.Direct2D1");
UseWindowingSubsystem("Avalonia.Win32");
}
return this;
}
/// <summary>
/// Sets up the platform-speciic services for the <see cref="Application"/>.
/// </summary>
@ -167,6 +169,11 @@ namespace Avalonia.Controls
throw new InvalidOperationException("No App instance configured.");
}
if (RuntimePlatformServices == null)
{
throw new InvalidOperationException("No runtime platform services configured.");
}
if (WindowingSubsystem == null)
{
throw new InvalidOperationException("No windowing system configured.");
@ -178,6 +185,7 @@ namespace Avalonia.Controls
}
Instance.RegisterServices();
RuntimePlatformServices();
WindowingSubsystem();
RenderingSubsystem();
Instance.Initialize();

14
src/Avalonia.DesignerSupport/DesignerAssist.cs

@ -37,8 +37,11 @@ namespace Avalonia.DesignerSupport
{
Design.IsDesignMode = true;
Api = new DesignerApi(shared) {UpdateXaml = UpdateXaml, UpdateXaml2 = UpdateXaml2, SetScalingFactor = SetScalingFactor};
var plat = (IPclPlatformWrapper) Activator.CreateInstance(Assembly.Load(new AssemblyName("Avalonia.Win32"))
.DefinedTypes.First(typeof (IPclPlatformWrapper).GetTypeInfo().IsAssignableFrom).AsType());
var runtimeAssembly = Assembly.Load(new AssemblyName("Avalonia.DotNetFrameworkRuntime"));
var plat = (IRuntimePlatform) Activator.CreateInstance(runtimeAssembly
.DefinedTypes.First(typeof (IRuntimePlatform).GetTypeInfo().IsAssignableFrom).AsType());
TypeInfo app = null;
var asms = plat.GetLoadedAssemblies();
@ -58,7 +61,12 @@ namespace Avalonia.DesignerSupport
//Ignore, Assembly.DefinedTypes threw an exception, we can't do anything about that
}
}
AppBuilder.Configure(app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType()))
var builderType = runtimeAssembly.GetType("Avalonia.AppBuilder");
var builder = (dynamic)Activator.CreateInstance(builderType,
app == null ? new DesignerApp() : (Application) Activator.CreateInstance(app.AsType()));
builder
.UseWindowingSubsystem("Avalonia.Win32")
.UseRenderingSubsystem("Avalonia.Direct2D1")
.SetupWithoutStarting();

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

@ -12,7 +12,7 @@ namespace Avalonia
{
public static class GtkApplicationExtensions
{
public static AppBuilder UseCairo(this AppBuilder builder)
public static T UseCairo<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.RenderingSubsystem = Avalonia.Cairo.CairoPlatform.Initialize;
return builder;

1
src/Gtk/Avalonia.Gtk/Avalonia.Gtk.csproj

@ -95,5 +95,4 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\..\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" />
</Project>

4
src/Gtk/Avalonia.Gtk/GtkPlatform.cs

@ -8,14 +8,13 @@ using Avalonia.Controls.Platform;
using Avalonia.Input.Platform;
using Avalonia.Input;
using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport;
using Avalonia.Controls;
namespace Avalonia
{
public static class GtkApplicationExtensions
{
public static AppBuilder UseGtk(this AppBuilder builder)
public static T UseGtk<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.WindowingSubsystem = Avalonia.Gtk.GtkPlatform.Initialize;
return builder;
@ -56,7 +55,6 @@ namespace Avalonia.Gtk
.Bind<IPlatformThreadingInterface>().ToConstant(s_instance)
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialogImpl>()
.Bind<IPlatformIconLoader>().ToConstant(s_instance);
SharedPlatform.Register();
_uiThread = Thread.CurrentThread;
}

2
src/Markup/Avalonia.Markup.Xaml/Context/AvaloniaNamespaceRegistry.cs

@ -168,7 +168,7 @@ namespace Avalonia.Markup.Xaml.Context
private void ScanNewAssemblies()
{
IEnumerable<Assembly> assemblies = AvaloniaLocator.Current
.GetService<IPclPlatformWrapper>()
.GetService<IRuntimePlatform>()
?.GetLoadedAssemblies();
if (assemblies != null)

6
src/Shared/PlatformSupport/PlatformSupport.projitems

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AssetLoader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PclPlatformWrapper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)SharedPlatform.cs" />
<Compile Include="$(MSBuildThisFileDirectory)StandardRuntimePlatform.cs" />
<Compile Include="$(MSBuildThisFileDirectory)StandardRuntimePlatformServices.cs" />
</ItemGroup>
</Project>

4
src/Shared/PlatformSupport/PclPlatformWrapper.cs → src/Shared/PlatformSupport/StandardRuntimePlatform.cs

@ -10,7 +10,7 @@ using Avalonia.Platform;
namespace Avalonia.Shared.PlatformSupport
{
internal class PclPlatformWrapper : IPclPlatformWrapper
internal class StandardRuntimePlatform : IRuntimePlatform
{
public Assembly[] GetLoadedAssemblies() => AppDomain.CurrentDomain.GetAssemblies();
public void PostThreadPoolItem(Action cb) => ThreadPool.UnsafeQueueUserWorkItem(_ => cb(), null);
@ -23,6 +23,8 @@ namespace Avalonia.Shared.PlatformSupport
return Disposable.Create(() => timer.Dispose());
}
public string GetStackTrace() => Environment.StackTrace;
}
}

4
src/Shared/PlatformSupport/SharedPlatform.cs → src/Shared/PlatformSupport/StandardRuntimePlatformServices.cs

@ -6,12 +6,12 @@ using Avalonia.Platform;
namespace Avalonia.Shared.PlatformSupport
{
static class SharedPlatform
static class StandardRuntimePlatformServices
{
public static void Register(Assembly assembly = null)
{
AvaloniaLocator.CurrentMutable
.Bind<IPclPlatformWrapper>().ToSingleton<PclPlatformWrapper>()
.Bind<IRuntimePlatform>().ToSingleton<StandardRuntimePlatform>()
.Bind<IAssetLoader>().ToConstant(new AssetLoader(assembly));
}
}

2
src/Skia/Avalonia.Skia/SkiaPlatform.cs

@ -8,7 +8,7 @@ namespace Avalonia
{
public static class SkiaApplicationExtensions
{
public static AppBuilder UseSkia(this AppBuilder builder)
public static T UseSkia<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.RenderingSubsystem = Avalonia.Skia.SkiaPlatform.Initialize;
return builder;

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

@ -12,7 +12,7 @@ namespace Avalonia
{
public static class Direct2DApplicationExtensions
{
public static AppBuilder UseDirect2D1(this AppBuilder builder)
public static T UseDirect2D1<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.RenderingSubsystem = Avalonia.Direct2D1.Direct2D1Platform.Initialize;
return builder;

1
src/Windows/Avalonia.Win32/Avalonia.Win32.csproj

@ -114,7 +114,6 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="..\..\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" />
<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.

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

@ -12,7 +12,6 @@ using System.Threading;
using Avalonia.Controls.Platform;
using Avalonia.Input;
using Avalonia.Platform;
using Avalonia.Shared.PlatformSupport;
using Avalonia.Win32.Input;
using Avalonia.Win32.Interop;
using Avalonia.Controls;
@ -22,7 +21,7 @@ namespace Avalonia
{
public static class Win32ApplicationExtensions
{
public static AppBuilder UseWin32(this AppBuilder builder)
public static T UseWin32<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.WindowingSubsystem = Avalonia.Win32.Win32Platform.Initialize;
return builder;
@ -69,8 +68,7 @@ namespace Avalonia.Win32
.Bind<ISystemDialogImpl>().ToSingleton<SystemDialogImpl>()
.Bind<IWindowingPlatform>().ToConstant(s_instance)
.Bind<IPlatformIconLoader>().ToConstant(s_instance);
SharedPlatform.Register();
_uiThread = Thread.CurrentThread;
}

6
src/iOS/Avalonia.iOS/iOSPlatform.cs

@ -13,14 +13,14 @@ namespace Avalonia
{
public static class iOSApplicationExtensions
{
public static AppBuilder UseiOS(this AppBuilder builder)
public static T UseiOS<T>(this T builder) where T : AppBuilderBase<T>, new()
{
builder.WindowingSubsystem = Avalonia.iOS.iOSPlatform.Initialize;
return builder;
}
// TODO: Can we merge this with UseSkia somehow once HW/platform cleanup is done?
public static AppBuilder UseSkiaViewHost(this AppBuilder builder)
public static T UseSkiaViewHost<T>(this T builder) where T : AppBuilderBase<T>, new()
{
var window = new UIWindow(UIScreen.MainScreen.Bounds);
var controller = new AvaloniaViewController(window);
@ -53,7 +53,7 @@ namespace Avalonia.iOS
KeyboardDevice = new KeyboardDevice();
AvaloniaLocator.CurrentMutable
.Bind<IPclPlatformWrapper>().ToSingleton<PclPlatformWrapper>()
.Bind<IRuntimePlatform>().ToSingleton<StandardRuntimePlatform>()
.Bind<IClipboard>().ToTransient<Clipboard>()
// TODO: what does this look like for iOS??
//.Bind<ISystemDialogImpl>().ToTransient<SystemDialogImpl>()

4
tests/Avalonia.DesignerSupport.TestApp/Avalonia.DesignerSupport.TestApp.csproj

@ -85,6 +85,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj">
<Project>{4a1abb09-9047-4bd5-a4ad-a055e52c5ee0}</Project>
<Name>Avalonia.DotNetFrameworkRuntime</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj">
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project>
<Name>Avalonia.Animation</Name>

2
tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs

@ -149,7 +149,7 @@ namespace Avalonia.Layout.UnitTests
.Bind<IInputManager>().ToConstant(new Mock<IInputManager>().Object)
.Bind<IGlobalStyles>().ToConstant(globalStyles.Object)
.Bind<ILayoutManager>().ToConstant(new LayoutManager())
.Bind<IPclPlatformWrapper>().ToConstant(new PclPlatformWrapper())
.Bind<IRuntimePlatform>().ToConstant(new StandardRuntimePlatform())
.Bind<IPlatformRenderInterface>().ToConstant(renderInterface)
.Bind<IRenderQueueManager>().ToConstant(renderManager)
.Bind<IStyler>().ToConstant(new Styler())

14
tests/Avalonia.UnitTests/TestServices.cs

@ -19,7 +19,7 @@ namespace Avalonia.UnitTests
public static readonly TestServices StyledWindow = new TestServices(
assetLoader: new AssetLoader(),
layoutManager: new LayoutManager(),
platformWrapper: new PclPlatformWrapper(),
platform: new StandardRuntimePlatform(),
renderInterface: CreateRenderInterfaceMock(),
standardCursorFactory: Mock.Of<IStandardCursorFactory>(),
styler: new Styler(),
@ -31,7 +31,7 @@ namespace Avalonia.UnitTests
renderInterface: CreateRenderInterfaceMock());
public static readonly TestServices MockPlatformWrapper = new TestServices(
platformWrapper: Mock.Of<IPclPlatformWrapper>());
platform: Mock.Of<IRuntimePlatform>());
public static readonly TestServices MockStyler = new TestServices(
styler: Mock.Of<IStyler>());
@ -56,7 +56,7 @@ namespace Avalonia.UnitTests
IInputManager inputManager = null,
Func<IKeyboardDevice> keyboardDevice = null,
ILayoutManager layoutManager = null,
IPclPlatformWrapper platformWrapper = null,
IRuntimePlatform platform = null,
IPlatformRenderInterface renderInterface = null,
IStandardCursorFactory standardCursorFactory = null,
IStyler styler = null,
@ -70,7 +70,7 @@ namespace Avalonia.UnitTests
InputManager = inputManager;
KeyboardDevice = keyboardDevice;
LayoutManager = layoutManager;
PlatformWrapper = platformWrapper;
Platform = platform;
RenderInterface = renderInterface;
StandardCursorFactory = standardCursorFactory;
Styler = styler;
@ -85,7 +85,7 @@ namespace Avalonia.UnitTests
public IFocusManager FocusManager { get; }
public Func<IKeyboardDevice> KeyboardDevice { get; }
public ILayoutManager LayoutManager { get; }
public IPclPlatformWrapper PlatformWrapper { get; }
public IRuntimePlatform Platform { get; }
public IPlatformRenderInterface RenderInterface { get; }
public IStandardCursorFactory StandardCursorFactory { get; }
public IStyler Styler { get; }
@ -100,7 +100,7 @@ namespace Avalonia.UnitTests
IInputManager inputManager = null,
Func<IKeyboardDevice> keyboardDevice = null,
ILayoutManager layoutManager = null,
IPclPlatformWrapper platformWrapper = null,
IRuntimePlatform platform = null,
IPlatformRenderInterface renderInterface = null,
IStandardCursorFactory standardCursorFactory = null,
IStyler styler = null,
@ -115,7 +115,7 @@ namespace Avalonia.UnitTests
inputManager: inputManager ?? InputManager,
keyboardDevice: keyboardDevice ?? KeyboardDevice,
layoutManager: layoutManager ?? LayoutManager,
platformWrapper: platformWrapper ?? PlatformWrapper,
platform: platform ?? Platform,
renderInterface: renderInterface ?? RenderInterface,
standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
styler: styler ?? Styler,

2
tests/Avalonia.UnitTests/UnitTestApplication.cs

@ -41,7 +41,7 @@ namespace Avalonia.UnitTests
.Bind<IInputManager>().ToConstant(Services.InputManager)
.Bind<IKeyboardDevice>().ToConstant(Services.KeyboardDevice?.Invoke())
.Bind<ILayoutManager>().ToConstant(Services.LayoutManager)
.Bind<IPclPlatformWrapper>().ToConstant(Services.PlatformWrapper)
.Bind<IRuntimePlatform>().ToConstant(Services.Platform)
.Bind<IPlatformRenderInterface>().ToConstant(Services.RenderInterface)
.Bind<IPlatformThreadingInterface>().ToConstant(Services.ThreadingInterface)
.Bind<IStandardCursorFactory>().ToConstant(Services.StandardCursorFactory)

Loading…
Cancel
Save