Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
修复因DI使用不当造成的多实例创建的问题 (#1565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Nov 14, 2022
1 parent f8d0a69 commit 1db86ea
Show file tree
Hide file tree
Showing 94 changed files with 112 additions and 280 deletions.
2 changes: 1 addition & 1 deletion src/Adapter/Adapter.UnitTests/Adapter.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Update="FluentAssertions" Version="6.7.0" />
<PackageReference Update="FluentAssertions" Version="6.8.0" />
<PackageReference Update="FluentAssertions.Analyzers" Version="0.17.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
10 changes: 5 additions & 5 deletions src/App/App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1309,19 +1309,19 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI">
<Version>7.1.2</Version>
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Animations">
<Version>7.1.2</Version>
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Behaviors">
<Version>7.1.2</Version>
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>7.1.2</Version>
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Media">
<Version>7.1.2</Version>
<Version>7.1.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.8.2-prerelease.220830001</Version>
Expand Down
1 change: 0 additions & 1 deletion src/App/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ private async void OnLaunchedOrActivatedAsync(IActivatedEventArgs e)

// Place the frame in the current Window
Window.Current.Content = rootFrame;
DIFactory.RegisterAppRequiredConstants();
}

if (e is LaunchActivatedEventArgs && (e as LaunchActivatedEventArgs).PrelaunchActivated == false)
Expand Down
1 change: 0 additions & 1 deletion src/App/Controls/App/XboxNavigationView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.Linq;
using Bili.App.Controls.Base;
using Bili.App.Pages.Xbox;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.App.Other;
using Bili.ViewModels.Interfaces.Community;
using Windows.UI.Xaml.Controls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void OnDanmakuListAdded(object sender, IEnumerable<DanmakuInformation> e

private async void OnMediaPlayerChangedAsync(object sender, object e)
{
if(e is MediaPlayer mp)
if (e is MediaPlayer mp)
{
_mediaPlayerElement.SetMediaPlayer(mp);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.ComponentModel;
using Bili.Models.Data.Player;
using Windows.UI.Xaml;
Expand Down
1 change: 0 additions & 1 deletion src/App/Controls/Player/InteractionChoicePanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.Data.Player;
using Bili.ViewModels.Interfaces.Core;
using Windows.UI.Xaml;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Windows.UI.Xaml;

namespace Bili.App.Controls.Player.PlayerControls
Expand Down
1 change: 0 additions & 1 deletion src/App/Controls/Player/SubtitleConfigPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.Data.Player;
using Bili.ViewModels.Interfaces.Common;
using Windows.UI.Xaml;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/ArticlePartitionPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.Data.Community;
using Bili.Models.Enums;
using Bili.ViewModels.Interfaces.Article;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/DynamicPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.App.Other;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/FavoritePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.Linq;
using Bili.App.Pages.Base;
using Bili.Models.App.Other;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;
using Bili.Models.Data.Live;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/LivePartitionPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/LivePlayerPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Local;
using Windows.UI.Xaml.Navigation;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/MessagePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.ViewModels.Interfaces.Community;

namespace Bili.App.Pages.Desktop.Overlay
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/MyFollowsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.Data.Community;
using Bili.ViewModels.Interfaces.Account;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/PgcIndexPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.Linq;
using Bili.Models.Data.Appearance;
using Bili.Models.Enums;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/SearchPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Appearance;
using Bili.ViewModels.Interfaces.Search;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/Overlay/UserSpacePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.User;
using Windows.UI.Xaml.Navigation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;
using Bili.Models.Enums;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Desktop/RankPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/FavoritePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using System.Linq;
using Bili.App.Pages.Base;
using Bili.Models.App.Other;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/LivePartitionDetailPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;
using Bili.Models.Data.Live;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/LivePartitionPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/SearchPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Appearance;
using Bili.ViewModels.Interfaces.Search;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/UserSpacePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.User;
using Windows.UI.Xaml.Navigation;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/Overlay/VideoFavoriteDetailPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Video;
using Windows.UI.Xaml.Navigation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;
using Bili.Models.Enums;
Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/PreSearchPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.Models.Data.Search;
using Bili.ViewModels.Interfaces.Search;

Expand Down
1 change: 0 additions & 1 deletion src/App/Pages/Xbox/RankPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright (c) Richasy. All rights reserved.

using System;
using Bili.App.Pages.Base;
using Bili.Models.Data.Community;

Expand Down
2 changes: 1 addition & 1 deletion src/App/Resources/Converter/PreferQualityConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal sealed class PreferQualityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if(value is PreferQuality quality)
if (value is PreferQuality quality)
{
var resToolkit = Locator.Instance.GetService<IResourceToolkit>();
return quality switch
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/DI.App/DI.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>5.0.4</Version>
<Version>5.0.5</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
12 changes: 1 addition & 11 deletions src/Lib/DI.App/DIFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
using Bili.ViewModels.Uwp.Toolbox;
using Bili.ViewModels.Uwp.Video;
using Windows.Storage;
using Windows.UI.Xaml;

namespace Bili.DI.App
{
Expand All @@ -52,7 +51,7 @@ public static void RegisterAppRequiredServices()
NLog.GlobalDiagnosticsContext.Set("LogPath", fullPath);
var logger = NLog.LogManager.GetLogger("Richasy.Bili");
Container.Locator.Instance
.RegisterSingleton<NLog.ILogger>(logger)
.RegisterConstant(logger)
.RegisterSingleton<IResourceToolkit, ResourceToolkit>()
.RegisterSingleton<INumberToolkit, NumberToolkit>()
.RegisterSingleton<ISettingsToolkit, SettingsToolkit>()
Expand Down Expand Up @@ -179,14 +178,5 @@ public static void RegisterAppRequiredServices()
.RegisterSingleton<ILivePlayerPageViewModel, LivePlayerPageViewModel>()
.Build();
}

/// <summary>
/// 注册应用所需的常量.
/// </summary>
public static void RegisterAppRequiredConstants()
{
Container.Locator.Instance.RegisterSingleton(Window.Current.CoreWindow.Dispatcher)
.Build();
}
}
}
2 changes: 1 addition & 1 deletion src/Lib/DI.Container/DI.Container.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.4.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit 1db86ea

Please sign in to comment.