Add netstandard1.0 (PCL) support
This commit is contained in:
parent
00d14adcf1
commit
a0e45ab61a
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Ooui
|
||||
{
|
||||
|
@ -21,7 +22,7 @@ namespace Ooui
|
|||
public IReadOnlyList<Message> StateMessages {
|
||||
get {
|
||||
lock (stateMessages) {
|
||||
return new List<Message> (stateMessages).AsReadOnly ();
|
||||
return new ReadOnlyList<Message> (stateMessages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +243,7 @@ namespace Ooui
|
|||
|
||||
public override bool CanConvert (Type objectType)
|
||||
{
|
||||
return typeof (EventTarget).IsAssignableFrom (objectType);
|
||||
return typeof (EventTarget).GetTypeInfo ().IsAssignableFrom (objectType.GetTypeInfo ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
27
Ooui/Node.cs
27
Ooui/Node.cs
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
@ -11,7 +12,7 @@ namespace Ooui
|
|||
public IReadOnlyList<Node> Children {
|
||||
get {
|
||||
lock (children) {
|
||||
return new List<Node> (children).AsReadOnly ();
|
||||
return new ReadOnlyList<Node> (children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -200,4 +201,28 @@ namespace Ooui
|
|||
|
||||
public abstract void WriteOuterHtml (System.Xml.XmlWriter w);
|
||||
}
|
||||
|
||||
class ReadOnlyList<T> : IReadOnlyList<T>
|
||||
{
|
||||
readonly List<T> list;
|
||||
|
||||
public ReadOnlyList (List<T> items)
|
||||
{
|
||||
list = new List<T> (items);
|
||||
}
|
||||
|
||||
T IReadOnlyList<T>.this[int index] => list[index];
|
||||
|
||||
int IReadOnlyCollection<T>.Count => list.Count;
|
||||
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator ()
|
||||
{
|
||||
return ((IEnumerable<T>)list).GetEnumerator ();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator ()
|
||||
{
|
||||
return ((IEnumerable)list).GetEnumerator ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,18 @@
|
|||
<PackageProjectUrl>https://github.com/praeclarum/Ooui</PackageProjectUrl>
|
||||
<PackageLicenseUrl>https://github.com/praeclarum/Ooui/blob/master/LICENSE</PackageLicenseUrl>
|
||||
<RepositoryUrl>https://github.com/praeclarum/Ooui.git</RepositoryUrl>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFrameworks>netstandard2.0;netstandard1.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" $(TargetFramework) == 'netstandard1.0' ">
|
||||
<DefineConstants>PCL</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Client.js" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -7,6 +7,14 @@ namespace Ooui
|
|||
{
|
||||
static class Platform
|
||||
{
|
||||
#if PCL
|
||||
|
||||
public static void OpenBrowser (string url, object presenter)
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static readonly Assembly iosAssembly;
|
||||
static readonly Type iosUIViewControllerType;
|
||||
static readonly Type iosUIApplicationType;
|
||||
|
@ -130,7 +138,7 @@ namespace Ooui
|
|||
return t;
|
||||
}
|
||||
|
||||
static Process StartBrowserProcess (string url)
|
||||
static void StartBrowserProcess (string url)
|
||||
{
|
||||
// var vs = Environment.GetEnvironmentVariables ();
|
||||
// foreach (System.Collections.DictionaryEntry kv in vs) {
|
||||
|
@ -139,9 +147,14 @@ namespace Ooui
|
|||
|
||||
// Console.WriteLine ($"Process.Start {cmd} {args}");
|
||||
|
||||
return Environment.OSVersion.Platform == PlatformID.Unix
|
||||
? Process.Start ("open", url)
|
||||
: Process.Start (new ProcessStartInfo (url) { UseShellExecute = true });
|
||||
if (Environment.OSVersion.Platform == PlatformID.Unix) {
|
||||
Process.Start ("open", url);
|
||||
}
|
||||
else {
|
||||
Process.Start (new ProcessStartInfo (url) { UseShellExecute = true });
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,8 +412,19 @@ namespace Ooui
|
|||
return null;
|
||||
if (val is string s)
|
||||
return s;
|
||||
|
||||
if (val is int i)
|
||||
return i + units;
|
||||
if (val is double d)
|
||||
return d.ToString (System.Globalization.CultureInfo.InvariantCulture) + units;
|
||||
if (val is float f)
|
||||
return f.ToString (System.Globalization.CultureInfo.InvariantCulture) + units;
|
||||
|
||||
#if !PCL
|
||||
if (val is IConvertible c)
|
||||
return c.ToString (System.Globalization.CultureInfo.InvariantCulture) + units;
|
||||
#endif
|
||||
|
||||
return val.ToString ();
|
||||
}
|
||||
|
||||
|
@ -431,8 +442,17 @@ namespace Ooui
|
|||
return num;
|
||||
}
|
||||
|
||||
if (v is int i)
|
||||
return i;
|
||||
if (v is double d)
|
||||
return d;
|
||||
if (v is float f)
|
||||
return f;
|
||||
|
||||
#if !PCL
|
||||
if (v is IConvertible c)
|
||||
return c.ToDouble (System.Globalization.CultureInfo.InvariantCulture);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
19
Ooui/UI.cs
19
Ooui/UI.cs
|
@ -6,12 +6,17 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
#if !PCL
|
||||
using System.Net.WebSockets;
|
||||
#endif
|
||||
|
||||
namespace Ooui
|
||||
{
|
||||
public static class UI
|
||||
{
|
||||
#if !PCL
|
||||
|
||||
static readonly ManualResetEvent started = new ManualResetEvent (false);
|
||||
|
||||
[ThreadStatic]
|
||||
|
@ -22,12 +27,6 @@ namespace Ooui
|
|||
static readonly Dictionary<string, RequestHandler> publishedPaths =
|
||||
new Dictionary<string, RequestHandler> ();
|
||||
|
||||
static readonly Dictionary<string, Style> styles =
|
||||
new Dictionary<string, Style> ();
|
||||
static readonly StyleSelectors rules = new StyleSelectors ();
|
||||
|
||||
public static StyleSelectors Styles => rules;
|
||||
|
||||
static readonly byte[] clientJsBytes;
|
||||
static readonly string clientJsEtag;
|
||||
|
||||
|
@ -809,6 +808,14 @@ namespace Ooui
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static readonly Dictionary<string, Style> styles =
|
||||
new Dictionary<string, Style> ();
|
||||
static readonly StyleSelectors rules = new StyleSelectors ();
|
||||
|
||||
public static StyleSelectors Styles => rules;
|
||||
|
||||
public class StyleSelectors
|
||||
{
|
||||
public Style this[string selector] {
|
||||
|
|
Loading…
Reference in New Issue