Skip to content

Commit f7431cd

Browse files
committed
update plugin manager
1 parent 77b03cd commit f7431cd

27 files changed

+1471
-330
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,5 @@ FodyWeavers.xsd
401401
*.sln.iml
402402
docs/Story/.keep
403403
/.idea/.idea.Modulus/.idea
404+
405+
.DS_Store

Modulus.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{D1B4
2121
EndProject
2222
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimplePlugin", "src\samples\SimplePlugin\SimplePlugin.csproj", "{253D6931-730D-463D-A157-C5471278C785}"
2323
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modulus.Plugin.Abstractions", "src\Modulus.Plugin.Abstractions\Modulus.Plugin.Abstractions.csproj", "{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}"
25+
EndProject
2426
Global
2527
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2628
Debug|Any CPU = Debug|Any CPU
@@ -41,6 +43,7 @@ Global
4143
{F90DD49A-A54E-41DE-8461-3FC1AAABDC4D}.Release|x64.Build.0 = Release|Any CPU
4244
{F90DD49A-A54E-41DE-8461-3FC1AAABDC4D}.Release|x86.ActiveCfg = Release|Any CPU
4345
{F90DD49A-A54E-41DE-8461-3FC1AAABDC4D}.Release|x86.Build.0 = Release|Any CPU
46+
{F90DD49A-A54E-41DE-8461-3FC1AAABDC4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
4447
{13583974-8926-4153-8A6E-B8724B767D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4548
{13583974-8926-4153-8A6E-B8724B767D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
4649
{13583974-8926-4153-8A6E-B8724B767D45}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -101,6 +104,18 @@ Global
101104
{253D6931-730D-463D-A157-C5471278C785}.Release|x64.Build.0 = Release|Any CPU
102105
{253D6931-730D-463D-A157-C5471278C785}.Release|x86.ActiveCfg = Release|Any CPU
103106
{253D6931-730D-463D-A157-C5471278C785}.Release|x86.Build.0 = Release|Any CPU
107+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
108+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
109+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|x64.ActiveCfg = Debug|Any CPU
110+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|x64.Build.0 = Debug|Any CPU
111+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|x86.ActiveCfg = Debug|Any CPU
112+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Debug|x86.Build.0 = Debug|Any CPU
113+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
114+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|Any CPU.Build.0 = Release|Any CPU
115+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|x64.ActiveCfg = Release|Any CPU
116+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|x64.Build.0 = Release|Any CPU
117+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|x86.ActiveCfg = Release|Any CPU
118+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF}.Release|x86.Build.0 = Release|Any CPU
104119
EndGlobalSection
105120
GlobalSection(SolutionProperties) = preSolution
106121
HideSolutionNode = FALSE
@@ -113,5 +128,6 @@ Global
113128
{02EA681E-C7D8-13C7-8484-4AC65E1B71E8} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
114129
{D1B4CF99-7947-DD6C-81D0-5B5B3989814C} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
115130
{253D6931-730D-463D-A157-C5471278C785} = {D1B4CF99-7947-DD6C-81D0-5B5B3989814C}
131+
{976EB4B8-F7B3-42C9-B285-BBB11514F8BF} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
116132
EndGlobalSection
117133
EndGlobal

build/_build.csproj.DotSettings

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=HeapView_002EDelegateAllocation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
33
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableHidesOuterVariable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
44
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassNeverInstantiated_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
@@ -17,11 +17,15 @@
1717
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
1818
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
1919
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
20+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=4a98fdf6_002D7d98_002D4f5a_002Dafeb_002Dea44ad98c70c/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
21+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=f9fce829_002De6f4_002D4cb2_002D80f1_002D5497c44f51df/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
2022
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
2123
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
2224
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2325
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
26+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
2427
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
2528
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
2629
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
27-
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
30+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
31+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

src/Modulus.App/App.axaml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,59 @@
66

77
<Application.Styles>
88
<FluentTheme />
9+
10+
<Style Selector="Button.transparent">
11+
<Setter Property="Background" Value="Transparent"/>
12+
<Setter Property="BorderThickness" Value="0"/>
13+
</Style>
14+
<Style Selector="Button.transparent:pointerover /template/ ContentPresenter">
15+
<Setter Property="Background" Value="{DynamicResource SystemFillColorNeutralSubtleSecondary}"/>
16+
</Style>
17+
<Style Selector="Button.transparent:pressed /template/ ContentPresenter">
18+
<Setter Property="Background" Value="{DynamicResource SystemFillColorNeutralSubtleTertiary}"/>
19+
</Style>
20+
21+
<!-- 卡片式切换按钮样式 -->
22+
<Style Selector="ToggleButton">
23+
<Setter Property="Background" Value="Transparent"/>
24+
<Setter Property="BorderThickness" Value="0"/>
25+
<Setter Property="Padding" Value="8"/>
26+
<Setter Property="CornerRadius" Value="4"/>
27+
</Style>
28+
<Style Selector="ToggleButton:pointerover /template/ ContentPresenter">
29+
<Setter Property="Background" Value="{DynamicResource SystemFillColorNeutralSubtleSecondary}"/>
30+
</Style>
31+
<Style Selector="ToggleButton:checked /template/ ContentPresenter">
32+
<Setter Property="Background" Value="{DynamicResource SystemAccentColorLight3}"/>
33+
</Style>
34+
35+
<!-- 危险按钮样式 -->
36+
<Style Selector="Button.danger">
37+
<Setter Property="Background" Value="Transparent"/>
38+
<Setter Property="BorderThickness" Value="0"/>
39+
<Setter Property="Padding" Value="8"/>
40+
<Setter Property="CornerRadius" Value="4"/>
41+
<Setter Property="Foreground" Value="{DynamicResource SystemFillColorCritical}"/>
42+
</Style>
43+
<Style Selector="Button.danger:pointerover /template/ ContentPresenter">
44+
<Setter Property="Background" Value="{DynamicResource SystemFillColorCriticalSubtleSecondary}"/>
45+
</Style>
46+
<Style Selector="Button.danger:pressed /template/ ContentPresenter">
47+
<Setter Property="Background" Value="{DynamicResource SystemFillColorCriticalSubtleTertiary}"/>
48+
</Style>
49+
50+
<!-- 插件卡片样式 -->
51+
<Style Selector="Border.plugin-card">
52+
<Setter Property="Background" Value="{DynamicResource SystemAltHighColor}"/>
53+
<Setter Property="BorderThickness" Value="1"/>
54+
<Setter Property="BorderBrush" Value="{DynamicResource SystemControlTransparentBrush}"/>
55+
<Setter Property="CornerRadius" Value="8"/>
56+
<Setter Property="Margin" Value="0,0,16,16"/>
57+
<Setter Property="Padding" Value="16"/>
58+
</Style>
59+
<Style Selector="Border.plugin-card:pointerover">
60+
<Setter Property="BorderBrush" Value="{DynamicResource SystemAccentColorLight2}"/>
61+
<Setter Property="Background" Value="{DynamicResource SystemAltMediumHighColor}"/>
62+
</Style>
963
</Application.Styles>
10-
11-
1264
</Application>

src/Modulus.App/App.axaml.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
using Microsoft.Extensions.Options;
1212
using System;
1313
using System.IO;
14+
using Serilog;
15+
using Serilog.Events;
1416

1517
namespace Modulus.App;
1618

@@ -33,12 +35,30 @@ public override void OnFrameworkInitializationCompleted()
3335
// Without this line you will get duplicate validations from both Avalonia and CT
3436
BindingPlugins.DataValidators.RemoveAt(0);
3537

38+
// Configure Serilog
39+
Log.Logger = new LoggerConfiguration()
40+
.MinimumLevel.Debug()
41+
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
42+
.Enrich.FromLogContext()
43+
.WriteTo.Debug()
44+
.WriteTo.File(Path.Combine(AppContext.BaseDirectory, "logs", "modulus-.log"), rollingInterval: RollingInterval.Day)
45+
// Add other sinks like remote service if needed
46+
.CreateLogger();
47+
48+
Log.Information("Application Starting...");
49+
3650
// 配置服务
3751
ConfigureServices();
3852

3953
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
4054
{
41-
var mainViewModel = _serviceProvider!.GetRequiredService<MainWindowViewModel>();
55+
if (_serviceProvider == null)
56+
{
57+
// Handle the case where _serviceProvider is null, perhaps log an error or throw an exception
58+
// For now, let's throw an exception as this indicates a critical initialization failure.
59+
throw new InvalidOperationException("Service provider is not initialized.");
60+
}
61+
var mainViewModel = _serviceProvider.GetRequiredService<MainWindowViewModel>();
4262
desktop.MainWindow = new MainWindow(mainViewModel);
4363

4464
// 启动配置更改监听器
@@ -84,9 +104,15 @@ private void ConfigureServices()
84104

85105
var services = new ServiceCollection();
86106

107+
// Add Serilog to the service collection
108+
services.AddLogging(loggingBuilder => loggingBuilder.AddSerilog(dispose: true));
109+
87110
// 注册配置服务
88111
services.AddSingleton<IConfiguration>(_configuration);
89112

113+
// Register IPluginService and its implementation
114+
services.AddSingleton<IPluginService, PluginService>();
115+
90116
// 注册选项(支持热重载和验证)
91117
services.AddOptions<AppOptions>()
92118
.Bind(_configuration.GetSection(AppOptions.SectionName))

0 commit comments

Comments
 (0)