Skip to content

Commit

Permalink
Fix Prism service locator issue, upgrade to latest nugets
Browse files Browse the repository at this point in the history
- Remove `CommonServiceLocator` nuget, use `Prism.Ioc.ContainerLocator.Container` instead
- Remove implicit `Unity.Container` nuget, bundled by `Prism.Unity`
- Upgrade nugets, remove version overrides
  • Loading branch information
angularsen committed Dec 29, 2024
1 parent 4d6d16c commit 0f552b9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 37 deletions.
6 changes: 2 additions & 4 deletions Samples/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
<ItemGroup>
<PackageVersion Include="UnitsNet" Version="5.65.0" />
<PackageVersion Include="MahApps.Metro" Version="2.4.10" />
<PackageVersion Include="CommonServiceLocator" Version="2.0.4" />
<PackageVersion Include="Prism.Container.Abstractions" Version="9.0.106" />
<PackageVersion Include="Prism.Unity" Version="7.1.0.431" />
<PackageVersion Include="Prism.Wpf" Version="7.1.0.431" />
<PackageVersion Include="Prism.Unity" Version="9.0.537" />
<PackageVersion Include="Prism.Wpf" Version="9.0.537" />
<PackageVersion Include="Unity.Abstractions" Version="5.11.7" />
<PackageVersion Include="Unity.Container" Version="5.8.11" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)

protected override Window CreateShell()
{
return new MainWindow();
return Container.Resolve<MainWindow>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
using CommonServiceLocator;
using Prism.Ioc;
using UnitsNet;
using WpfMVVMSample.Settings;

Expand All @@ -22,7 +22,7 @@ public UnitToStringConverter()
{
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
_settings = ServiceLocator.Current.GetInstance<SettingsManager>();
_settings = Prism.Ioc.ContainerLocator.Container.Resolve<SettingsManager>();
}
}

Expand Down
15 changes: 1 addition & 14 deletions Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows;

namespace WpfMVVMSample
{
Expand Down
11 changes: 1 addition & 10 deletions Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
using Prism.Commands;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Prism.Mvvm;
using UnitsNet;
using UnitsNet.Units;
using WpfMVVMSample.Converters;
using WpfMVVMSample.Properties;
using WpfMVVMSample.Settings;

namespace WpfMVVMSample
Expand Down
8 changes: 2 additions & 6 deletions Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<!-- managing these dependencies is a nightmare -->
<!-- note: there also seem to be breaking changes in the later versions: was getting an InvalidOperationException while trying to access ServiceLocator.Current -->
<PackageReference Include="CommonServiceLocator" OverrideVersion="2.0.4"/>
<PackageReference Include="Prism.Unity" OverrideVersion="7.1.0.431" />
<PackageReference Include="Prism.Wpf" OverrideVersion="7.1.0.431"/>
<PackageReference Include="Unity.Container" OverrideVersion="5.8.11"/>
<PackageReference Include="Prism.Unity" />
<PackageReference Include="Prism.Wpf" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
Expand Down

0 comments on commit 0f552b9

Please sign in to comment.