Implement Xamarin.Forms 5.0 functions

This commit is contained in:
Frank A. Krueger 2021-05-09 11:27:13 -07:00
parent db453bb0f9
commit efada143d0
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
4 changed files with 31 additions and 29 deletions

View File

@ -7,6 +7,8 @@ using System.Threading;
using System.Threading.Tasks;
using Ooui;
using System.Net.Http;
using System.Collections.Generic;
using System.Linq;
namespace Xamarin.Forms
{
@ -59,7 +61,7 @@ namespace Xamarin.Forms
public string RuntimePlatform => "Ooui";
public OSAppTheme RequestedTheme => throw new NotImplementedException();
public OSAppTheme RequestedTheme => OSAppTheme.Unspecified;
public void BeginInvokeOnMainThread (Action action)
{
@ -177,14 +179,20 @@ namespace Xamarin.Forms
public string GetHash(string input)
{
return Utilities.GetHash(input);
}
static readonly Dictionary<string, Color> colorNames =
typeof (Color)
.GetFields (BindingFlags.Static | BindingFlags.Public)
.Where(x => x.FieldType == typeof(Color))
.ToDictionary (x => x.Name, x => (Color)x.GetValue (null));
public Color GetNamedColor(string name)
{
throw new NotImplementedException();
if (colorNames.TryGetValue (name, out var color))
return color;
return Color.Default;
}
}

View File

@ -1,21 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<UserSecretsId>aspnet-AspNetCoreMvc-F1609F62-F713-4EFE-9B42-D8206BFB2F63</UserSecretsId>
<StartupObject></StartupObject>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Ooui.AspNetCore\Ooui.AspNetCore.csproj" />
<ProjectReference Include="..\..\Ooui\Ooui.csproj" />

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace AspNetCoreMvc
@ -14,13 +15,13 @@ namespace AspNetCoreMvc
{
public static void Main (string[] args)
{
BuildWebHost (args).Run ();
CreateHostBuilder (args).Build ().Run ();
}
public static IWebHost BuildWebHost (string[] args) =>
WebHost.CreateDefaultBuilder (args)
.UseConfiguration (new ConfigurationBuilder ().AddCommandLine (args).Build ())
.UseStartup<Startup> ()
.Build ();
public static IHostBuilder CreateHostBuilder (string[] args) =>
Host.CreateDefaultBuilder (args)
.ConfigureWebHostDefaults (webBuilder => {
webBuilder.UseStartup<Startup> ();
});
}
}

View File

@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace AspNetCoreMvc
{
@ -21,30 +19,33 @@ namespace AspNetCoreMvc
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices (IServiceCollection services)
{
services.AddMvc ();
services.AddControllersWithViews ();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure (IApplicationBuilder app, IHostingEnvironment env)
public void Configure (IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment ()) {
app.UseDeveloperExceptionPage ();
}
else {
app.UseExceptionHandler ("/Home/Error");
app.UseHsts ();
}
//app.UseHttpsRedirection ();
app.UseStaticFiles ();
app.UseRouting ();
app.UseOoui ();
Xamarin.Forms.Forms.Init ();
app.UseMvc (routes => {
routes.MapRoute (
app.UseEndpoints (endpoints => {
endpoints.MapControllerRoute (
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
}