-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add Tizen platform support (#1546)
- Loading branch information
1 parent
f2290c2
commit e3eb8ef
Showing
12 changed files
with
219 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using NuGet; | ||
using Polly; | ||
using Serilog; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace EventBuilder.Platforms | ||
{ | ||
public class Tizen : BasePlatform | ||
{ | ||
private const string _packageName = "Tizen.NET"; | ||
|
||
public Tizen() | ||
{ | ||
var packageUnzipPath = Environment.CurrentDirectory; | ||
|
||
Log.Debug($"Package unzip path is {packageUnzipPath}"); | ||
|
||
var retryPolicy = Policy | ||
.Handle<Exception>() | ||
.WaitAndRetry( | ||
5, | ||
retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), | ||
(exception, timeSpan, context) => { | ||
Log.Warning( | ||
"An exception was thrown whilst retrieving or installing {0}: {1}", | ||
_packageName, exception); | ||
}); | ||
|
||
retryPolicy.Execute(() => { | ||
var repo = PackageRepositoryFactory.Default.CreateRepository("https://packages.nuget.org/api/v2"); | ||
var packageManager = new PackageManager(repo, packageUnzipPath); | ||
var package = repo.FindPackagesById(_packageName).Single(x => x.Version.ToString() == "4.0.0"); | ||
Log.Debug("Using Tizen.NET {0} released on {1}", package.Version, package.Published); | ||
Log.Debug("{0}", package.ReleaseNotes); | ||
packageManager.InstallPackage(package, ignoreDependencies: true, allowPrereleaseVersions: false); | ||
}); | ||
|
||
var elmSharp = Directory.GetFiles(packageUnzipPath, "ElmSharp*.dll", SearchOption.AllDirectories); | ||
Assemblies.AddRange(elmSharp); | ||
|
||
var tizenNet = Directory.GetFiles(packageUnzipPath, "Tizen*.dll", SearchOption.AllDirectories); | ||
Assemblies.AddRange(tizenNet); | ||
|
||
CecilSearchDirectories.Add($"{packageUnzipPath}\\Tizen.NET.4.0.0\\build\\tizen40\\ref"); | ||
CecilSearchDirectories.Add($"{packageUnzipPath}\\Tizen.NET.4.0.0\\lib\\netstandard2.0"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Reactive.Concurrency; | ||
using System.Reactive.Disposables; | ||
using ElmSharp; | ||
|
||
namespace ReactiveUI | ||
{ | ||
class EcoreMainloopScheduler : IScheduler | ||
{ | ||
public static IScheduler MainThreadScheduler = new EcoreMainloopScheduler(); | ||
|
||
public DateTimeOffset Now => DateTimeOffset.Now; | ||
|
||
public IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
var innerDisp = new SingleAssignmentDisposable(); | ||
EcoreMainloop.PostAndWakeUp(() => { | ||
if (!innerDisp.IsDisposed) innerDisp.Disposable = action(this, state); | ||
}); | ||
return innerDisp; | ||
} | ||
|
||
public IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
var innerDisp = Disposable.Empty; | ||
bool isCancelled = false; | ||
|
||
IntPtr timer = EcoreMainloop.AddTimer(dueTime.TotalSeconds, () => { | ||
if (!isCancelled) innerDisp = action(this, state); | ||
return false; | ||
}); | ||
|
||
return Disposable.Create(() => { | ||
isCancelled = true; | ||
EcoreMainloop.RemoveTimer(timer); | ||
innerDisp.Dispose(); | ||
}); | ||
} | ||
|
||
public IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action) | ||
{ | ||
if (dueTime <= Now) { | ||
return Schedule(state, action); | ||
} | ||
return Schedule(state, dueTime - Now, action); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace ReactiveUI | ||
{ | ||
/// <summary> | ||
/// Returns the current orientation of the device on tizen. | ||
/// </summary> | ||
public class PlatformOperations : IPlatformOperations | ||
{ | ||
public string GetOrientation() | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MS-PL license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Reactive.Concurrency; | ||
|
||
namespace ReactiveUI | ||
{ | ||
public class PlatformRegistrations : IWantsToRegisterStuff | ||
{ | ||
public void Register(Action<Func<object>, Type> registerFunction) | ||
{ | ||
registerFunction(() => new PlatformOperations(), typeof(IPlatformOperations)); | ||
registerFunction(() => new ComponentModelTypeConverter(), typeof(IBindingTypeConverter)); | ||
RxApp.TaskpoolScheduler = TaskPoolScheduler.Default; | ||
RxApp.MainThreadScheduler = EcoreMainloopScheduler.MainThreadScheduler; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters