11 changed files with 316 additions and 2893 deletions
@ -0,0 +1,50 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
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> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
|
||||
|
/// </summary>
|
||||
|
public AppBuilder() |
||||
|
: base(new StandardRuntimePlatform(), () => StandardRuntimePlatformServices.Register()) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="AppBuilder"/> class.
|
||||
|
/// </summary>
|
||||
|
/// <param name="app">The <see cref="Application"/> instance.</param>
|
||||
|
public AppBuilder(Application app) : this() |
||||
|
{ |
||||
|
Instance = app; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Instructs the <see cref="AppBuilder"/> to use the best settings for the platform.
|
||||
|
/// </summary>
|
||||
|
/// <returns>An <see cref="AppBuilder"/> instance.</returns>
|
||||
|
public AppBuilder UsePlatformDetect() |
||||
|
{ |
||||
|
//We don't have the ability to load every assembly right now, so we are
|
||||
|
//stuck with manual configuration here
|
||||
|
if (RuntimePlatform.GetRuntimeInfo().OperatingSystem == OperatingSystemType.WinNT) |
||||
|
this.UseWin32(); |
||||
|
else |
||||
|
{ |
||||
|
//TODO: Register GTK3
|
||||
|
} |
||||
|
//TODO: Register Skia#
|
||||
|
|
||||
|
return this; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -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> |
||||
|
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> |
||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
|
<ProjectGuid>{7863EA94-F0FB-4386-BF8C-E5BFA761560A}</ProjectGuid> |
||||
|
<OutputType>Library</OutputType> |
||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||
|
<RootNamespace>Avalonia.DotNetCoreRuntime</RootNamespace> |
||||
|
<AssemblyName>Avalonia.DotNetCoreRuntime</AssemblyName> |
||||
|
<DefaultLanguage>en-US</DefaultLanguage> |
||||
|
<FileAlignment>512</FileAlignment> |
||||
|
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
||||
|
<TargetFrameworkProfile> |
||||
|
</TargetFrameworkProfile> |
||||
|
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
|
<DebugSymbols>true</DebugSymbols> |
||||
|
<DebugType>full</DebugType> |
||||
|
<Optimize>false</Optimize> |
||||
|
<OutputPath>bin\Debug\</OutputPath> |
||||
|
<DefineConstants>TRACE;DEBUG;NETSTANDARD</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<DocumentationFile>bin\Debug\Avalonia.DotNetCoreRuntime.XML</DocumentationFile> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
|
<DebugType>pdbonly</DebugType> |
||||
|
<Optimize>true</Optimize> |
||||
|
<OutputPath>bin\Release\</OutputPath> |
||||
|
<DefineConstants>TRACE;NETSTANDARD</DefineConstants> |
||||
|
<ErrorReport>prompt</ErrorReport> |
||||
|
<WarningLevel>4</WarningLevel> |
||||
|
<DocumentationFile>bin\Release\Avalonia.DotNetCoreRuntime.XML</DocumentationFile> |
||||
|
</PropertyGroup> |
||||
|
<ItemGroup> |
||||
|
<!-- A reference to the entire .NET Framework is automatically included --> |
||||
|
<None Include="project.json" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Compile Include="..\Shared\SharedAssemblyInfo.cs"> |
||||
|
<Link>SharedAssemblyInfo.cs</Link> |
||||
|
</Compile> |
||||
|
<Compile Include="AppBuilder.cs" /> |
||||
|
<Compile Include="NetCoreRuntimePlatform.cs" /> |
||||
|
<Compile Include="RuntimeInfo.cs" /> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj"> |
||||
|
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
||||
|
<Name>Avalonia.Base</Name> |
||||
|
</ProjectReference> |
||||
|
<ProjectReference Include="..\Avalonia.Controls\Avalonia.Controls.csproj"> |
||||
|
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
||||
|
<Name>Avalonia.Controls</Name> |
||||
|
</ProjectReference> |
||||
|
<ProjectReference Include="..\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
||||
|
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
||||
|
<Name>Avalonia.Visuals</Name> |
||||
|
</ProjectReference> |
||||
|
<ProjectReference Include="..\Windows\Avalonia.Win32.NetStandard\Avalonia.Win32.NetStandard.csproj"> |
||||
|
<Project>{40759a76-d0f2-464e-8000-6ff0f5c4bd7c}</Project> |
||||
|
<Name>Avalonia.Win32.NetStandard</Name> |
||||
|
</ProjectReference> |
||||
|
</ItemGroup> |
||||
|
<ItemGroup> |
||||
|
<Folder Include="Properties\" /> |
||||
|
</ItemGroup> |
||||
|
<Import Project="..\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" /> |
||||
|
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.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> |
||||
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Diagnostics; |
||||
|
using System.Linq; |
||||
|
using System.Reflection; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.DotNet.PlatformAbstractions; |
||||
|
using Microsoft.Extensions.DependencyModel; |
||||
|
|
||||
|
namespace Avalonia.Shared.PlatformSupport |
||||
|
{ |
||||
|
internal partial class StandardRuntimePlatform |
||||
|
{ |
||||
|
public Assembly[] GetLoadedAssemblies() |
||||
|
{ |
||||
|
List<Assembly> assemblies = new List<Assembly>(); |
||||
|
// Mostly copy-pasted from (MIT):
|
||||
|
// https://github.com/StefH/System.AppDomain.Core/blob/0b35e676c2721aa367b96e62eb52c97ee0b43a70/src/System.AppDomain.NetCoreApp/AppDomain.cs
|
||||
|
foreach (var assemblyName in DependencyContext.Default.GetRuntimeAssemblyNames(RuntimeEnvironment.GetRuntimeIdentifier())) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
var assembly = Assembly.Load(assemblyName); |
||||
|
// just load all types and skip this assembly if one or more types cannot be resolved
|
||||
|
assembly.DefinedTypes.ToArray(); |
||||
|
assemblies.Add(assembly); |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Debug.Write(ex.Message); |
||||
|
} |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
Debug.Write(ex.Message); |
||||
|
} |
||||
|
} |
||||
|
return assemblies.OrderBy(a => a.FullName).ToArray(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Platform; |
||||
|
|
||||
|
|
||||
|
namespace Avalonia.Shared.PlatformSupport |
||||
|
{ |
||||
|
internal partial class StandardRuntimePlatform |
||||
|
{ |
||||
|
private static readonly Lazy<RuntimePlatformInfo> Info = new Lazy<RuntimePlatformInfo>(() => |
||||
|
{ |
||||
|
OperatingSystemType os; |
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
||||
|
os = OperatingSystemType.OSX; |
||||
|
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
os = OperatingSystemType.Linux; |
||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
||||
|
os = OperatingSystemType.WinNT; |
||||
|
else |
||||
|
throw new Exception("Unknown OS platform " + RuntimeInformation.OSDescription); |
||||
|
|
||||
|
return new RuntimePlatformInfo |
||||
|
{ |
||||
|
IsCoreClr = true, |
||||
|
IsDesktop = true, |
||||
|
IsDotNetFramework = false, |
||||
|
IsMono = false, |
||||
|
IsMobile = false, |
||||
|
IsUnix = os != OperatingSystemType.WinNT, |
||||
|
OperatingSystem = os, |
||||
|
}; |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
public RuntimePlatformInfo GetRuntimeInfo() => Info.Value; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
{ |
||||
|
"supports": {}, |
||||
|
"dependencies": { |
||||
|
"Microsoft.NETCore.Portable.Compatibility": "1.0.1", |
||||
|
"NETStandard.Library": "1.6.1" |
||||
|
}, |
||||
|
"frameworks": { |
||||
|
"netstandard1.6": { |
||||
|
"dependencies": { |
||||
|
"System.Threading.ThreadPool": "4.3.0", |
||||
|
"Microsoft.Extensions.DependencyModel": "1.1.0" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
Loading…
Reference in new issue