Skip to content

Commit

Permalink
Merge pull request #184 from dansiegel/shinyupdate
Browse files Browse the repository at this point in the history
Shiny v2 updates
  • Loading branch information
dansiegel authored Feb 24, 2021
2 parents f1bcfef + 29c2c61 commit 044921b
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 104 deletions.
2 changes: 1 addition & 1 deletion sample/PrismSample.Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public MainApplication(IntPtr javaReference, JniHandleOwnership transfer)
public override void OnCreate()
{
base.OnCreate();
AndroidShinyHost.Init(this, new Startup());
this.ShinyOnCreate(new Startup());
}
}
}
4 changes: 2 additions & 2 deletions sample/PrismSample.Android/PrismSample.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
<AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk>
<TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
<AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
<AndroidUseAapt2>true</AndroidUseAapt2>
<AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
Expand Down Expand Up @@ -53,7 +53,7 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
<PackageReference Include="Xamarin.Android.Support.Core.Utils" Version="28.0.0.3" />
</ItemGroup>
<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions sample/PrismSample.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.prismlibrary.prismextensions">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="Prism Extended"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29" />
<application android:label="Prism Extended"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
4 changes: 2 additions & 2 deletions sample/PrismSample.Android/Resources/layout/Tabbar.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.tabs.TabLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
Expand All @@ -8,4 +8,4 @@
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:tabIndicatorColor="@android:color/white"
app:tabGravity="fill"
app:tabMode="fixed" />
app:tabMode="fixed" />
4 changes: 2 additions & 2 deletions sample/PrismSample.Android/Resources/layout/Toolbar.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<android.support.v7.widget.Toolbar
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

2 changes: 1 addition & 1 deletion sample/PrismSample.Android/SplashActivity.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Content;
using Android.Util;
using AndroidX.AppCompat.App;

namespace PrismSample.Droid
{
Expand Down
9 changes: 4 additions & 5 deletions sample/PrismSample.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Shiny;
using PrismSample.Shiny;

namespace PrismSample.UWP
{
Expand All @@ -30,6 +32,7 @@ public App()
{
this.InitializeComponent();
this.Suspending += OnSuspending;
this.ShinyInit(new Startup());
}

/// <summary>
Expand All @@ -39,13 +42,9 @@ public App()
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{


Frame rootFrame = Window.Current.Content as Frame;

// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
if (!(Window.Current.Content is Frame rootFrame))
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
Expand Down
18 changes: 17 additions & 1 deletion sample/PrismSample.UWP/PrismSample.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,26 @@
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.12" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Prism.Container.Extensions\Prism.Container.Extensions.csproj">
<Project>{940ca2d8-b9a8-499a-9ed3-ecee9758073f}</Project>
<Name>Prism.Container.Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Prism.DryIoc.Extensions\Prism.DryIoc.Extensions.csproj">
<Project>{3a82a96a-f3fc-4244-87c3-28706494f614}</Project>
<Name>Prism.DryIoc.Extensions</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Prism.Forms.Extended\Prism.Forms.Extended.csproj">
<Project>{771a0fd7-7877-4ab7-8528-7fb07054393d}</Project>
<Name>Prism.Forms.Extended</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Shiny.Prism\Shiny.Prism.csproj">
<Project>{fd30086e-fa39-408e-935f-8921b454d282}</Project>
<Name>Shiny.Prism</Name>
</ProjectReference>
<ProjectReference Include="..\PrismSample\PrismSample.csproj">
<Project>{0C2D6820-FA64-4050-9546-BF034329D363}</Project>
<Name>PrismSample</Name>
Expand Down
2 changes: 1 addition & 1 deletion sample/PrismSample.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsAppli
//
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
iOSShinyHost.Init(new Startup());
this.ShinyFinishedLaunching(new Startup());
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());

Expand Down
2 changes: 1 addition & 1 deletion sample/PrismSample.iOS/PrismSample.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<Reference Include="System.Numerics.Vectors" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion sample/PrismSample/PrismSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 3 additions & 6 deletions sample/PrismSample/Shiny/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Shiny;
using Shiny.Prism;
using Shiny.Power;

namespace PrismSample.Shiny
{
public class Startup : PrismStartup
{
protected override void ConfigureServices(IServiceCollection services)
protected override void ConfigureServices(IServiceCollection services, IPlatform platform)
{
// Register Stuff
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Prism.Core" Version="8.0.0.1909" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Prism.DryIoc.Extensions/Prism.DryIoc.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DryIoc.dll" Version="4.5.1" />
<PackageReference Include="DryIoc.dll" Version="4.7.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Prism.Unity.Extensions/Prism.Unity.Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Unity.Container" Version="5.11.10" />
<PackageReference Include="Unity.Container" Version="5.11.11" />
</ItemGroup>

<ItemGroup>
Expand Down
38 changes: 12 additions & 26 deletions src/Shiny.Prism/PrismStartup.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Prism.Container.Extensions.Internals;
using Prism.Ioc;
using Prism.Modularity;
Expand All @@ -19,26 +20,30 @@ protected PrismStartup(IContainerExtension container)
WithContainer(container);
}

protected virtual void ConfigureApp(IServiceProvider provider) { }
protected virtual void ConfigureLogging(ILoggingBuilder builder, IPlatform platform) { }

protected abstract void ConfigureServices(IServiceCollection services);
protected abstract void ConfigureServices(IServiceCollection services, IPlatform platform);

void IShinyStartup.ConfigureServices(IServiceCollection services)
protected virtual void RegisterServices(IContainerRegistry containerRegistry) { }

void IShinyStartup.ConfigureLogging(ILoggingBuilder builder, IPlatform platform) =>
ConfigureLogging(builder, platform);

void IShinyStartup.ConfigureServices(IServiceCollection services, IPlatform platform)
{
ConfigureServices(services);
ConfigureServices(services, platform);
services.RegisterPrismCoreServices();
services.Remove(services.First(x => x.ServiceType == typeof(IModuleInitializer)));
services.AddSingleton<IModuleInitializer, ShinyPrismModuleInitializer>();
}

void IShinyStartup.ConfigureApp(IServiceProvider provider) => ConfigureApp(provider);

IServiceProvider IShinyStartup.CreateServiceProvider(IServiceCollection services)
{
var container = ContainerLocationHelper.LocateContainer(CreateContainerExtension()) ??
throw new NullReferenceException("Call PrismContainerExtension.Init() prior to initializing PrismApplication");

var sp = container.CreateServiceProvider(services);
RegisterServices(container);

var moduleCatalog = container.Resolve<IModuleCatalog>();
ConfigureModuleCatalog(moduleCatalog);
Expand All @@ -60,29 +65,10 @@ protected virtual IContainerExtension CreateContainerExtension()
public IShinyStartup WithContainer(IContainerExtension container)
{
ContainerLocator.SetContainerExtension(() => container);
var _ = ContainerLocator.Container;
return this;
}

protected virtual void ConfigureModuleCatalog(IModuleCatalog moduleCatalog) { }
}

//public abstract class PrismStartupTask : IShinyStartupTask
//{
// async void IShinyStartupTask.Start()
// {
// try
// {
// Start();
// await StartAsync();
// }
// catch (Exception ex)
// {
// Log.Write(ex);
// }
// }

// protected virtual void Start() { }

// protected virtual Task StartAsync() => Task.CompletedTask;
//}
}
2 changes: 1 addition & 1 deletion src/Shiny.Prism/Shiny.Prism.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Shiny.Core" Version="1.2.0.1755" />
<PackageReference Include="Shiny.Core" Version="2.0.0.2508-preview" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Xunit;
using Prism.Ioc;
using System.Net.Http;
using Microsoft.Extensions.Logging;
#if DRYIOC
using Prism.DryIoc;
#elif UNITY
Expand Down Expand Up @@ -131,6 +132,24 @@ public void ResolvesHttpClientWithHttpClientFactory()
Assert.NotNull(client);
}

[Fact]
public void RegistersOpenGenerics()
{
PrismContainerExtension.Current.RegisterServices(s =>
{
s.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning));
});

ILogger<CommonAspNetServiceTests> logger = null;
var ex = Record.Exception(() =>
{
logger = PrismContainerExtension.Current.Resolve<ILogger<CommonAspNetServiceTests>>();
});

Assert.Null(ex);
Assert.NotNull(logger);
}

private void ConfigureServices()
{
var services = new ServiceCollection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
<PackageReference Include="Xamarin.Forms.Mocks" Version="4.7.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Xamarin.Forms" Version="4.8.0.1364" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2012" />
<PackageReference Include="Xamarin.Forms.Mocks" Version="4.7.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.10" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Loading

0 comments on commit 044921b

Please sign in to comment.