diff --git a/build.cake b/build.cake
index dfcda3596..3fd6fdbe0 100644
--- a/build.cake
+++ b/build.cake
@@ -78,6 +78,7 @@ var packageWhitelist = new[]
{
"Splat",
"Splat.Autofac",
+ "Splat.DryIoc",
"Splat.SimpleInjector",
};
@@ -85,6 +86,7 @@ var packageTestWhitelist = new[]
{
"Splat.Tests",
"Splat.Autofac.Tests",
+ "Splat.DryIoc.Tests",
"Splat.SimpleInjector.Tests",
};
diff --git a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj
index 110463ba2..e792b4c54 100644
--- a/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj
+++ b/src/Splat.Autofac.Tests/Splat.Autofac.Tests.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/src/Splat.DryIoc.Tests/DependencyResolverTests.cs b/src/Splat.DryIoc.Tests/DependencyResolverTests.cs
new file mode 100644
index 000000000..301b3d8f5
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/DependencyResolverTests.cs
@@ -0,0 +1,127 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using DryIoc;
+using ReactiveUI;
+using Shouldly;
+using Xunit;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// Tests to show the works correctly.
+ ///
+ public class DependencyResolverTests
+ {
+ ///
+ /// Shoulds the resolve views.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Resolve_Views()
+ {
+ var container = new Container();
+ container.Register, ViewOne>();
+ container.Register, ViewTwo>();
+ container.UseDryIocDependencyResolver();
+
+ var viewOne = Locator.Current.GetService(typeof(IViewFor));
+ var viewTwo = Locator.Current.GetService(typeof(IViewFor));
+
+ viewOne.ShouldNotBeNull();
+ viewOne.ShouldBeOfType();
+ viewTwo.ShouldNotBeNull();
+ viewTwo.ShouldBeOfType();
+ }
+
+ ///
+ /// Shoulds the resolve views.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Resolve_Named_View()
+ {
+ var container = new Container();
+ container.Register, ViewTwo>(serviceKey: "Other");
+ container.UseDryIocDependencyResolver();
+
+ var viewTwo = Locator.Current.GetService(typeof(IViewFor), "Other");
+
+ viewTwo.ShouldNotBeNull();
+ viewTwo.ShouldBeOfType();
+ }
+
+ ///
+ /// Shoulds the resolve view models.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Resolve_View_Models()
+ {
+ var container = new Container();
+ container.Register();
+ container.Register();
+ container.UseDryIocDependencyResolver();
+
+ var vmOne = Locator.Current.GetService();
+ var vmTwo = Locator.Current.GetService();
+
+ vmOne.ShouldNotBeNull();
+ vmTwo.ShouldNotBeNull();
+ }
+
+ ///
+ /// Shoulds the resolve screen.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Resolve_Screen()
+ {
+ var builder = new Container();
+ builder.Register(Reuse.Singleton);
+ builder.UseDryIocDependencyResolver();
+
+ var screen = Locator.Current.GetService();
+
+ screen.ShouldNotBeNull();
+ screen.ShouldBeOfType();
+ }
+
+ ///
+ /// Shoulds register ReactiveUI binding type converters.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Register_ReactiveUI_BindingTypeConverters()
+ {
+ // Invoke RxApp which initializes the ReactiveUI platform.
+ var scheduler = RxApp.MainThreadScheduler;
+ var container = new Container();
+ container.UseDryIocDependencyResolver();
+
+ var converters = container.Resolve>().ToList();
+
+ converters.ShouldNotBeNull();
+ converters.ShouldContain(x => x.GetType() == typeof(StringConverter));
+ converters.ShouldContain(x => x.GetType() == typeof(EqualityTypeConverter));
+ }
+
+ ///
+ /// Shoulds register ReactiveUI creates command bindings.
+ ///
+ [Fact]
+ public void DryIocDependencyResolver_Should_Register_ReactiveUI_CreatesCommandBinding()
+ {
+ // Invoke RxApp which initializes the ReactiveUI platform.
+ var scheduler = RxApp.MainThreadScheduler;
+ var container = new Container();
+ container.UseDryIocDependencyResolver();
+
+ var converters = container.Resolve>().ToList();
+
+ converters.ShouldNotBeNull();
+ converters.ShouldContain(x => x.GetType() == typeof(CreatesCommandBindingViaEvent));
+ converters.ShouldContain(x => x.GetType() == typeof(CreatesCommandBindingViaCommandParameter));
+ }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs b/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs
new file mode 100644
index 000000000..11a81fc76
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Mocks/MockScreen.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using ReactiveUI;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// An implementation.
+ ///
+ ///
+ public class MockScreen : IScreen
+ {
+ ///
+ /// Gets the Router associated with this Screen.
+ ///
+ public RoutingState Router { get; }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs b/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs
new file mode 100644
index 000000000..ecf61ae4d
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Mocks/ViewModelOne.cs
@@ -0,0 +1,23 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using ReactiveUI;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// View Model One.
+ ///
+ ///
+ ///
+ public class ViewModelOne : ReactiveObject, IRoutableViewModel
+ {
+ ///
+ public string UrlPathSegment { get; }
+
+ ///
+ public IScreen HostScreen { get; }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs b/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs
new file mode 100644
index 000000000..3dbfade1d
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Mocks/ViewModelTwo.cs
@@ -0,0 +1,23 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using ReactiveUI;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// View Model Two.
+ ///
+ ///
+ ///
+ public class ViewModelTwo : ReactiveObject, IRoutableViewModel
+ {
+ ///
+ public string UrlPathSegment { get; }
+
+ ///
+ public IScreen HostScreen { get; }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs b/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs
new file mode 100644
index 000000000..4dbcf91b0
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Mocks/ViewOne.cs
@@ -0,0 +1,26 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using ReactiveUI;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// View One.
+ ///
+ ///
+ public class ViewOne : IViewFor
+ {
+ ///
+ object IViewFor.ViewModel
+ {
+ get => ViewModel;
+ set => ViewModel = (ViewModelOne)value;
+ }
+
+ ///
+ public ViewModelOne ViewModel { get; set; }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs b/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs
new file mode 100644
index 000000000..501b0f212
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Mocks/ViewTwo.cs
@@ -0,0 +1,27 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using ReactiveUI;
+
+namespace Splat.DryIoc.Tests
+{
+ ///
+ /// View Two.
+ ///
+ ///
+ [ViewContract("Other")]
+ public class ViewTwo : IViewFor
+ {
+ ///
+ object IViewFor.ViewModel
+ {
+ get => ViewModel;
+ set => ViewModel = (ViewModelTwo)value;
+ }
+
+ ///
+ public ViewModelTwo ViewModel { get; set; }
+ }
+}
diff --git a/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj
new file mode 100644
index 000000000..69c4b3b3f
--- /dev/null
+++ b/src/Splat.DryIoc.Tests/Splat.DryIoc.Tests.csproj
@@ -0,0 +1,25 @@
+
+
+
+ netcoreapp2.1;net472
+
+ false
+ $(NoWarn);1591;CA1707;SA1633
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Always
+
+
+
+
diff --git a/src/Splat.DryIoc/DryIocDependencyResolver.cs b/src/Splat.DryIoc/DryIocDependencyResolver.cs
new file mode 100644
index 000000000..98afdb74b
--- /dev/null
+++ b/src/Splat.DryIoc/DryIocDependencyResolver.cs
@@ -0,0 +1,107 @@
+// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using DryIoc;
+
+namespace Splat.DryIoc
+{
+ ///
+ /// DryIoc implementation for .
+ /// https://bitbucket.org/dadhi/dryioc/wiki/Home.
+ ///
+ ///
+ public class DryIocDependencyResolver : IMutableDependencyResolver
+ {
+ private Container _container;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The container.
+ public DryIocDependencyResolver(Container container = null)
+ {
+ _container = container ?? new Container();
+ }
+
+ ///
+ public object GetService(Type serviceType, string contract = null) =>
+ string.IsNullOrEmpty(contract)
+ ? _container.Resolve(serviceType, IfUnresolved.ReturnDefault)
+ : _container.Resolve(serviceType, contract, IfUnresolved.ReturnDefault);
+
+ ///
+ public IEnumerable